當前位置: 首頁>>代碼示例>>C#>>正文


C# Delegate.GetInvocationList方法代碼示例

本文整理匯總了C#中System.Delegate.GetInvocationList方法的典型用法代碼示例。如果您正苦於以下問題:C# Delegate.GetInvocationList方法的具體用法?C# Delegate.GetInvocationList怎麽用?C# Delegate.GetInvocationList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Delegate的用法示例。


在下文中一共展示了Delegate.GetInvocationList方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ValidateCallback

 // Token: 0x06001860 RID: 6240
 // RVA: 0x00014E5C File Offset: 0x0001305C
 private static void ValidateCallback(Delegate delegate_0)
 {
     if (delegate_0 != null && delegate_0.GetInvocationList().Length > 1)
     {
         throw new NotSupportedException("SmartThreadPool doesn't support delegates chains");
     }
 }
開發者ID:newchild,項目名稱:Project-DayZero,代碼行數:9,代碼來源:WorkItemFactory.cs

示例2: Invoke

        /// <summary>
        /// Invokes a method delegate asynchrounously and thread safe.
        /// </summary>
        /// <param name="method">The delegate method to invoke</param>
        /// <param name="args">The arguments passed to the delegate.</param>
        public static void Invoke(Delegate method, object[] args)
        {
            if (method != null)
            {
                foreach (Delegate handler in method.GetInvocationList())
                {
                    if (handler.Target is Control)
                    {
                        Control target = handler.Target as Control;

                        if (target.IsHandleCreated)
                        {
                            target.BeginInvoke(handler, args);
                        }
                    }
                    else if (handler.Target is ISynchronizeInvoke)
                    {
                        ISynchronizeInvoke target = handler.Target as ISynchronizeInvoke;
                        target.BeginInvoke(handler, args);
                    }
                    else
                    {
                        handler.DynamicInvoke(args);
                    }
                }
            }
        }
開發者ID:ilkerde,項目名稱:pipemania,代碼行數:32,代碼來源:ThreadSafe.cs

示例3: AddTaskDelay

        private static void AddTaskDelay(Delegate ev, object[] paramArray, int time)
        {
            System.Threading.Thread.Sleep(time);
            bool bFired;

            if (ev != null)
            {
                foreach (Delegate singleCast in ev.GetInvocationList())
                {
                    bFired = false;
                    try
                    {
                        ISynchronizeInvoke syncInvoke = (ISynchronizeInvoke)singleCast.Target;
                        if (syncInvoke != null && syncInvoke.InvokeRequired)
                        {
                            bFired = true;
                            syncInvoke.BeginInvoke(singleCast, paramArray);
                        }
                        else
                        {
                            bFired = true;
                            singleCast.DynamicInvoke(paramArray);
                        }
                    }
                    catch (Exception)
                    {
                        if (!bFired)
                            singleCast.DynamicInvoke(paramArray);
                    }
                }
            }
        }
開發者ID:Xileck,項目名稱:tibiaapi,代碼行數:32,代碼來源:Scheduler.cs

示例4: GetDelegateList

        public static Delegate[] GetDelegateList(Delegate del)
        {
            if(del == null) {
                throw new ArgumentNullException("del");
            }

            return del.GetInvocationList();
        }
開發者ID:gratianlup,項目名稱:DebugUtils,代碼行數:8,代碼來源:DelegateHelper.cs

示例5: DisplayDelegateInfo

 public static void DisplayDelegateInfo(Delegate del)
 {
     foreach (var item in del.GetInvocationList())
     {
         Console.WriteLine("Method Name {0}", del.Method);
         Console.WriteLine("Type Name {0}", del.Target);
     }
 }
開發者ID:TatevAghasaryan,項目名稱:ToMIC,代碼行數:8,代碼來源:Program.cs

示例6: ReadDelegate

 private void ReadDelegate( Delegate delObj )
 {
     foreach (Delegate del in delObj.GetInvocationList())
      {
     Console.WriteLine("Method {0}", del.Method);
     Console.WriteLine("Target {0}", del.Target);
      }
 }
開發者ID:ghostmonk,項目名稱:CSharpTutorials,代碼行數:8,代碼來源:DelegationAndSuch.cs

示例7: DisplayDelegateInfo

 static void DisplayDelegateInfo(Delegate delObj)
 {
     foreach (Delegate d in delObj.GetInvocationList())
     {
         Console.WriteLine("Method name: {0}", d.Method);
         Console.WriteLine("Type name: {0}", d.Target);
     }
 }
開發者ID:volkoff-pro,項目名稱:Troelsen.CSharp,代碼行數:8,代碼來源:Program.cs

示例8: GetDelegateDetails

 public static void GetDelegateDetails(Delegate d)
 {
     foreach (Delegate dg in d.GetInvocationList())
     {
         Console.WriteLine("Type is {0}",dg.GetType());
         Console.WriteLine("Method is {0}",dg.Method);
         Console.WriteLine("target is {0}",dg.Target);
     }
 }
開發者ID:ujjwalvaish,項目名稱:LearnCSharp-ThroughProjects,代碼行數:9,代碼來源:Program.cs

示例9: Handle

 private static void Handle(Delegate del, PacketHandlerEventArgs args, params object[] parameters)
 {
     if (del != null)
         foreach (Delegate d in del.GetInvocationList())
         {
             bool? result = (bool?)d.Method.Invoke(d.Target, parameters);
             if (result.HasValue)
                 args.Block = result.Value;
         }
 }
開發者ID:jaryn-kubik,項目名稱:RazorEx,代碼行數:10,代碼來源:Event.Messages.cs

示例10: DelegateMetadata

		/// <summary>
		///   Initializes a new instance.
		/// </summary>
		/// <param name="d">The delegate the info object should be created for.</param>
		public DelegateMetadata(Delegate d)
		{
			Requires.NotNull(d, nameof(d));

			_delegate = d;
			_delegateType = d.GetType();

			var list = d.GetInvocationList();
			_targets = list.Select(info => info.Target).ToArray();
			_methods = list.Select(info => info.Method).ToArray();
		}
開發者ID:isse-augsburg,項目名稱:ssharp,代碼行數:15,代碼來源:DelegateMetadata.cs

示例11: Cast

        private static dynamic Cast(Delegate source, Type type)
        {
            Delegate[] delegates = source.GetInvocationList();
            if (delegates.Length == 1)
                return Delegate.CreateDelegate(type,
                    delegates[0].Target, delegates[0].Method);

            Delegate[] delegatesDest = new Delegate[delegates.Length];
            for (int nDelegate = 0; nDelegate < delegates.Length; nDelegate++)
                delegatesDest[nDelegate] = Delegate.CreateDelegate(type,
                    delegates[nDelegate].Target, delegates[nDelegate].Method);
            return Delegate.Combine(delegatesDest);
        }
開發者ID:distantcam,項目名稱:zeromvvm,代碼行數:13,代碼來源:WindsorComponentRegistrationHelper.cs

示例12: InvokeAsync

 /// <summary>
 /// Invokes every delegate method in new thread (except synchronized handlers).
 /// </summary>
 /// <param name="handler"></param>
 /// <param name="parameters"></param>
 public static void InvokeAsync(Delegate handler, params object[] parameters)
 {
     if (handler != null) {
         foreach (Delegate d in handler.GetInvocationList()) {
             ISynchronizeInvoke sync = d.Target as ISynchronizeInvoke;
             if (sync != null) {
                 sync.BeginInvoke(d, parameters);
             }
             else {
                 ThreadPool.QueueUserWorkItem(new WaitCallback(AsyncInvokeProc), new AsyncInvokeArgs(d.Method, d.Target, parameters));
             }
         }
     }
 }
開發者ID:greeduomacro,項目名稱:phoenix,代碼行數:19,代碼來源:DelegateInvoker.cs

示例13: GetMethodList

        public static MethodInfo[] GetMethodList(Delegate del)
        {
            if(del == null) {
                throw new ArgumentNullException("del");
            }

            Delegate[] delegates = del.GetInvocationList();
            MethodInfo[] methods = new MethodInfo[delegates.Length];

            for(int i = 0; i < delegates.Length; i++) {
                methods[i] = delegates[i].Method;
            }

            return methods;
        }
開發者ID:gratianlup,項目名稱:DebugUtils,代碼行數:15,代碼來源:DelegateHelper.cs

示例14: RaiseEventOnUIThread

 public static void RaiseEventOnUIThread(Delegate theEvent, object[] args)
 {
     foreach (Delegate d in theEvent.GetInvocationList())
     {
         ISynchronizeInvoke syncer = d.Target as ISynchronizeInvoke;
         if (syncer == null)
         {
             d.DynamicInvoke(args);
         }
         else
         {
             syncer.BeginInvoke(d, args);  // cleanup omitted
         }
     }
 }
開發者ID:caiodossantos,項目名稱:wireless-network,代碼行數:15,代碼來源:EventHelper.cs

示例15: CallAsyncMethod

        public static void CallAsyncMethod(Delegate eventDelegate, params object[] args)
        {
            if (eventDelegate != null)
            {
                Delegate[] delegates = eventDelegate.GetInvocationList();

                AsyncInvokeDelegate invoker = new AsyncInvokeDelegate(InvokeDelegate);

                AsyncCallback cleanUp = new AsyncCallback(AsyncDelegateCleanup);

                foreach (Delegate sink in delegates)
                {
                    invoker.BeginInvoke(sink, args, cleanUp, null);
                }
            }
        }
開發者ID:hostitherepc,項目名稱:Fork-1,代碼行數:16,代碼來源:EventUtils.cs


注:本文中的System.Delegate.GetInvocationList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。