• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# System.MulticastDelegate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.MulticastDelegate的典型用法代码示例。如果您正苦于以下问题:C# MulticastDelegate类的具体用法?C# MulticastDelegate怎么用?C# MulticastDelegate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MulticastDelegate类属于System命名空间,在下文中一共展示了MulticastDelegate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: EventUnhooked

        public void EventUnhooked(MulticastDelegate eventHandler)
        {
            // The rest of the method must be inline or the stack trace won't be correct.
            StackTrace currentStackTrace = new StackTrace();

            // Make sure we were called from a "remove" method of an event.
            string callingEventMethodName = currentStackTrace.GetFrame(1).GetMethod().Name;
            Debug.Assert(callingEventMethodName.StartsWith("remove_", StringComparison.OrdinalIgnoreCase), "EventUnhooked called from an invalid method");
            string eventName = callingEventMethodName.Substring("remove_".Length);

            if (eventHandler == null)
            {
                // If the MulticastDelegate is null, then the event is completely unhooked.
                _eventsHooked.Remove(eventName);
                _eventsUnhooked.Remove(eventName);
            }
            else
            {
                // Save the current stack trace for debugging.
                if (!_eventsUnhooked.ContainsKey(eventName))
                    _eventsUnhooked[eventName] = new List<StackTrace>();

                _eventsUnhooked[eventName].Add(currentStackTrace);
            }
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:25,代码来源:EventCounter.cs


示例2: DisplayMulticastInfo

 static void DisplayMulticastInfo(MulticastDelegate md)
 {
     foreach(var d in md.GetInvocationList())
     {
         DisplayDelegateInfo(d);
     }
 }
开发者ID:beanordman,项目名称:Learning,代码行数:7,代码来源:Program.cs


示例3: InvokeMulticast

 public static void InvokeMulticast(object sender, MulticastDelegate md)
 {
     if (md != null)
     {
         InvokeMulticast(sender, md, null);
     }
 }
开发者ID:zhukunqian,项目名称:usmooth,代码行数:7,代码来源:UsUtil.cs


示例4: InvokeHandler

 private void InvokeHandler( MulticastDelegate handlerList, EventArgs e )
 {
     object[] args = new object[] { this, e };
     foreach( Delegate handler in handlerList.GetInvocationList() )
     {
         object target = handler.Target;
         System.Windows.Forms.Control control
             = target as System.Windows.Forms.Control;
         try
         {
             if ( control != null && control.InvokeRequired )
                 //control.Invoke( handler, args );
                 control.BeginInvoke(handler, args);
             else
                 handler.Method.Invoke( target, args );
         }
         catch( Exception ex )
         {
             // TODO: Stop rethrowing this since it goes back to the
             // Test domain which may not know how to handle it!!!
             Console.WriteLine( "Exception:" );
             Console.WriteLine( ex );
             //throw new TestEventInvocationException( ex );
             //throw;
         }
     }
 }
开发者ID:qunleinature,项目名称:nunitarxnet,代码行数:27,代码来源:GuiTestEventDispatcherArxNet.cs


示例5: FireEventToDelegates

		internal void FireEventToDelegates(MulticastDelegate md, ManagementEventArgs args)
		{
			try
			{
				if (md != null)
				{
					Delegate[] invocationList = md.GetInvocationList();
					for (int i = 0; i < (int)invocationList.Length; i++)
					{
						Delegate @delegate = invocationList[i];
						try
						{
							object[] objArray = new object[2];
							objArray[0] = this.sender;
							objArray[1] = args;
							@delegate.DynamicInvoke(objArray);
						}
						catch
						{
						}
					}
				}
			}
			catch
			{
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:27,代码来源:WmiDelegateInvoker.cs


示例6: CallEvent

        static public void CallEvent(string objMgPath, string eventName, MulticastDelegate delgt, params object[] eventParams)
        {
            try
            {
                delgt.DynamicInvoke(eventParams);
                if (!PurviewMgr.IsMainHost)
                {
                    object[] newparams = new object[eventParams.Length];

                    for (int i = 0; i < eventParams.Length; i++)
                    {
                        if (eventParams[i] is IGameObj)
                        {
                            newparams[i] = new GameObjSyncInfo(((IGameObj)eventParams[i]).MgPath);
                        }
                        else
                        {
                            newparams[i] = eventParams[i];
                        }

                    }

                    // 通过网络协议传递给主机
                    SyncCasheWriter.SubmitNewEvent(objMgPath, eventName, newparams);
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex.ToString());
            }
        }
开发者ID:ingex0,项目名称:smarttank,代码行数:31,代码来源:InfoRePath.cs


示例7: Remove

        /// <summary>
        /// Remove the given delegate from my invocation list.
        /// </summary>
        protected override sealed Delegate Remove(Delegate other)
        {
            if (this.Equals(other))
            {
                // Front of the list
                var result = next;
                next = null;
                return result;
            }

            MulticastDelegate parent = this;
            while ((parent != null) && (!other.Equals(parent.next)))
            {
                parent = parent.next;
            }

            if (parent != null)
            {
                MulticastDelegate otherx = parent.next;
                parent.next = otherx.next;
                otherx.next = null;
            }

            return this;
        }
开发者ID:rfcclub,项目名称:api,代码行数:28,代码来源:MulticastDelegate.cs


示例8: InvokeDelegates

        public static void InvokeDelegates(MulticastDelegate mDelegate, object sender, EventArgs e)
        {
            if (mDelegate == null)
                return;

            Delegate[] delegates = mDelegate.GetInvocationList();
            if (delegates == null)
                return;

            // Invoke delegates within their threads
            foreach (Delegate _delegate in delegates)
            {
                if (_delegate.Target.GetType().ContainsGenericParameters)
                {
                    Console.WriteLine("Cannot invoke event handler on a generic type.");
                    return;
                }

                object[] contextAndArgs = { sender, e };
                ISynchronizeInvoke syncInvoke = _delegate.Target as ISynchronizeInvoke;
                {
                    if (syncInvoke != null)
                    {
                        // This case applies to the situation when Delegate.Target is a 
                        // Control with an open window handle.
                        syncInvoke.Invoke(_delegate, contextAndArgs);
                    }
                    else
                    {
                        _delegate.DynamicInvoke(contextAndArgs);
                    }
                }
            }
        }
开发者ID:hhqqnu,项目名称:MSLyncProjects,代码行数:34,代码来源:UCMAObject.cs


示例9: DelegateFactory

        /// <summary>
        /// Initializes the class with the given <paramref name="targetDelegate"/>
        /// </summary>
        /// <param name="targetDelegate">The delegate that will be used to instantiate the factory.</param>
        public DelegateFactory(MulticastDelegate targetDelegate)
        {
            if (targetDelegate.Method.ReturnType == typeof(void))
                throw new ArgumentException("The factory delegate must have a return type.");

            _targetDelegate = targetDelegate;
        }
开发者ID:zxl359592450,项目名称:linfu,代码行数:11,代码来源:DelegateFactory.cs


示例10: BuildFor

 public static string BuildFor(MulticastDelegate action, string prefixToExclude)
 {
     var name = action.Method.Name;
     if (name.StartsWith(prefixToExclude, true, CultureInfo.CurrentCulture))
     {
         name = name.Substring(prefixToExclude.Length).TrimStart('_');
     }
     return BuildFor(name);
 }
开发者ID:mvbalaw,项目名称:FluentAssert,代码行数:9,代码来源:ActionDescriptionBuilder.cs


示例11: quadl

        /// <summary>Find integral using Lobatto Rule</summary>
        /// <param name="f">Function to integrate. Must be of the
        /// form y = f(x) where x and y are of type "double".</param>
        /// <param name="a">Lower bound of integral</param>
        /// <param name="b">Upper bound of integral</param>
        /// <returns>Area under funciton curve with an error of +- 1e-6</returns>
        /// 
        /// <remarks>
        /// Derived from "W. Gander and W. Gautschi: Adaptive Quadrature - 
        /// Revisited, BIT Vol. 40, No. 1, March 2000, pp. 84--101. CS technical 
        /// report: Report (gzipped, 82K). Programs: adaptsim.m, adaptlob.m", which
        /// can be found at: http://www.inf.ethz.ch/personal/gander/.
        /// 
        /// The defualt error of 1e-6 was chosen in order to give results
        /// comparible in speed and precision to Matlab R2009a.
        /// </remarks>
        public static double quadl(MulticastDelegate f, double a, double b)
        {
            double tol = 1e-6; // to have the same level of precision as Matlab
            // in the future, this could be an input?
            
            double m = (a + b) / 2.0;
            double h = (b - a) / 2.0;
            double alpha = Math.Sqrt(2.0 / 3.0);
            double beta = 1.0 / Math.Sqrt(5.0);

            double c1 = 0.942882415695480;
            double c2 = 0.641853342345781;
            double c3 = 0.236383199662150;

            double y1 = (double)f.DynamicInvoke(a),
                   y2 = (double)f.DynamicInvoke(m - c1 * h),
                   y3 = (double)f.DynamicInvoke(m - alpha * h),
                   y4 = (double)f.DynamicInvoke(m - c2 * h),
                   y5 = (double)f.DynamicInvoke(m - beta * h),
                   y6 = (double)f.DynamicInvoke(m - c3 * h),
                   y7 = (double)f.DynamicInvoke(m),
                   y8 = (double)f.DynamicInvoke(m + c3 * h),
                   y9 = (double)f.DynamicInvoke(m + beta * h),
                   y10= (double)f.DynamicInvoke(m + c2 * h),
                   y11= (double)f.DynamicInvoke(m + alpha * h),
                   y12= (double)f.DynamicInvoke(m + c1 * h),
                   y13= (double)f.DynamicInvoke(b);

            double fa = y1;
            double fb = y13;

            double i2 = (h / 6.0) * (y1 + y13 + 5 * (y5 + y9));
            double i1 = (h / 1470.0) * (77 * (y1 + y13) + 432 * (y3 + y11) + 625 * (y5 + y9) + 672 * y7);

            double i0 = h * (
                0.0158271919734802 * (y1 + y13) +
                0.0942738402188500 * (y2 + y12) +
                0.155071987336585 * (y3 + y11) +
                0.188821573960182 * (y4 + y10) +
                0.199773405226859 * (y5 + y9) +
                0.224926465333340 * (y6 + y8) +
                0.242611071901408 * y7);

            double s = (i0 >= 0) ? 1 : -1;

            double erri1 = Math.Abs(i1 - i0);
            double erri2 = Math.Abs(i2 - i0);

            double R = (erri2 == 0) ? 1 : erri1 / erri2;

            i0 = s * Math.Abs(i0) * tol / double.Epsilon;
            if (i0 == 0) i0 = b - a;

            return quadlStep(f, a, b, fa, fb, i0);
        }
开发者ID:wdxa,项目名称:ILNumerics,代码行数:71,代码来源:quadl.cs


示例12: Execute

 public override object Execute(MulticastDelegate dele, ParameterCollection parameters)
 {
     try
     {
         return dele.DynamicInvoke(parameters.AllParameterValues);
     }
     catch (Exception ex)
     {
         return this.ExecuteOnException(ex, parameters);
     }
 }
开发者ID:yong2579,项目名称:aspectsharp,代码行数:11,代码来源:CatchAdviceAttribute.cs


示例13: TrySetSlot

 public static bool TrySetSlot(MulticastDelegate multicastDelegate, object[] a, int index, object o)
 {
     if (a[index] == null)
       {
     a[index] = o;
       }
       if (a[index] != null)
       {
     return false;
       }
       return false;
 }
开发者ID:Zino2201,项目名称:Cosmos,代码行数:12,代码来源:MulticastDelegateImpl.cs


示例14: SafeMultiInvoke

		public static object[] SafeMultiInvoke(MulticastDelegate delegateToFire, params object[] parameters )
		{	
			Delegate[] invocationList = delegateToFire.GetInvocationList();		
			
			object[] retvals = new object[invocationList.Length];
			int i=0;			
			
			foreach (Delegate dlg in invocationList)
			{
				retvals[i++] = SafeInvoke(dlg, parameters);		
			}
			return retvals;
		}			
开发者ID:BrianGoff,项目名称:BITS,代码行数:13,代码来源:EventUtils.cs


示例15: Clone

 public MulticastDelegate Clone()
 {
     MulticastDelegate headClone = new MulticastDelegate(Target, Function);
     MulticastDelegate prevClone = headClone;
     MulticastDelegate current = headClone._next;
     MulticastDelegate clone;
     while (current != null)
     {
         clone = new MulticastDelegate(current.Target, current.Function);
         clone._prev = prevClone;
         prevClone = clone;
         current = current._next;
     }
     return headClone;
 }
开发者ID:sidecut,项目名称:xaeios,代码行数:15,代码来源:MulticastDelegate.cs


示例16: UnbindFromEvent

        public static void UnbindFromEvent(string eventName, object source, MulticastDelegate target)
        {
            if (source == null)
                throw new ArgumentNullException("source");

            Type sourceType = source.GetType();
            EventInfo targetEvent = sourceType.GetEvent(eventName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);

            if (targetEvent == null)
                throw new ArgumentException(
                string.Format("Event '{0}' was not found on source type '{1}'", eventName, sourceType.FullName));

            Type delegateType = targetEvent.EventHandlerType;
            targetEvent.RemoveEventHandler(source, target);
        }
开发者ID:jonfuller,项目名称:LinFu.DynamicObject,代码行数:15,代码来源:EventBinder.cs


示例17: InvocationListEquals

        private bool InvocationListEquals(MulticastDelegate d)
        {
            Delegate[] invocationList = m_helperObject as Delegate[];
            if (d.m_extraFunctionPointerOrData != m_extraFunctionPointerOrData)
                return false;

            int invocationCount = (int)m_extraFunctionPointerOrData;
            for (int i = 0; i < invocationCount; i++)
            {
                Delegate dd = invocationList[i];
                Delegate[] dInvocationList = d.m_helperObject as Delegate[];
                if (!dd.Equals(dInvocationList[i]))
                    return false;
            }
            return true;
        }
开发者ID:kyulee1,项目名称:corert,代码行数:16,代码来源:MulticastDelegate.cs


示例18: Execute

        public override object Execute(MulticastDelegate dele, ParameterCollection parameters)
        {
            try
            {
                return dele.DynamicInvoke(parameters.AllParameterValues);
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Black;
                Console.BackgroundColor = ConsoleColor.Red;

                Console.WriteLine(ex.Message);

                Console.ResetColor();

                throw;
            }
        }
开发者ID:yong2579,项目名称:aspectsharp,代码行数:18,代码来源:LogExceptionsAdviceAttribute.cs


示例19: Execute

        public override object Execute(MulticastDelegate dele, ParameterCollection parameters)
        {
            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("Prefix: {0}", _prefix);
            Console.WriteLine("Suffix: {0}", _suffix);
            Console.WriteLine("Name: {0}", this.Name);

            if (_allTypes != null)
            {
                Console.WriteLine("All types: {0}", _allTypes);
            }

            Console.WriteLine("Intercepted {0}::{1}", dele.Target.GetType().FullName, dele.Method.Name);

            if (parameters.Dictionary.Count > 0)
            {
                Console.WriteLine("Args:");

                foreach (KeyValuePair<string, object> kvp in parameters.Dictionary)
                {
                    Console.WriteLine("  {0} -> {1}", kvp.Key, kvp.Value);
                }
            }

            Console.ResetColor();

            // invoke the intercepted method
            object result = dele.DynamicInvoke(parameters.AllParameterValues);

            Console.ForegroundColor = ConsoleColor.Green;

            if (dele.Method.ReturnType != typeof(void))
            {
                Console.WriteLine("Return:");
                Console.WriteLine("  {0}", result);
            }

            Console.ResetColor();

            return result;
        }
开发者ID:yong2579,项目名称:aspectsharp,代码行数:42,代码来源:TraceAdviceAttribute.cs


示例20: InternalCombine

 protected override void InternalCombine(Delegate d)
 {
     MulticastDelegate current = this;
     while (current._next != null) // get to the end of the chain
     {
         //Console.WriteLine(" -> ");
         current = current._next;
     }
     MulticastDelegate multicastDelegate = d as MulticastDelegate;
     if (multicastDelegate == null)
     {
         //Console.WriteLine("Creating new secondary multicast delegate for InternalCombine");
         multicastDelegate = new MulticastDelegate(d.Target, d.Function);
     }
     else
     {
         //Console.WriteLine("Cloning secondary delegate for InternalCombine");
         multicastDelegate = multicastDelegate.Clone();
     }
     current._next = multicastDelegate;
     multicastDelegate._prev = current;
 }
开发者ID:sidecut,项目名称:xaeios,代码行数:22,代码来源:MulticastDelegate.cs



注:本文中的System.MulticastDelegate类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# System.NotImplementedException类代码示例发布时间:2022-05-26
下一篇:
C# System.Methods类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap