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


C# MulticastDelegate.GetInvocationList方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: DisplayMulticastInfo

 static void DisplayMulticastInfo(MulticastDelegate md)
 {
     foreach(var d in md.GetInvocationList())
     {
         DisplayDelegateInfo(d);
     }
 }
開發者ID:beanordman,項目名稱:Learning,代碼行數:7,代碼來源:Program.cs

示例5: 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

示例6: FireEventToDelegates

 internal void FireEventToDelegates(MulticastDelegate md, ManagementEventArgs args)
 {
     try
     {
         if (md != null)
         {
             foreach (Delegate delegate2 in md.GetInvocationList())
             {
                 try
                 {
                     delegate2.DynamicInvoke(new object[] { this.sender, args });
                 }
                 catch
                 {
                 }
             }
         }
     }
     catch
     {
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:22,代碼來源:WmiDelegateInvoker.cs

示例7: InvokeMulticast

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

            foreach (StdMulticastDelegation Caster in md.GetInvocationList())
            {
                ISynchronizeInvoke SyncInvoke = Caster.Target as ISynchronizeInvoke;
                try
                {
                    if (SyncInvoke != null && SyncInvoke.InvokeRequired)
                        SyncInvoke.Invoke(Caster, new object[] { sender, e });
                    else
                        Caster(sender, e);
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine("Event handling failed. \n");
                    Console.WriteLine("{0}:\n", ex.ToString());
                }
            }
        }
開發者ID:zhukunqian,項目名稱:usmooth,代碼行數:22,代碼來源:UsUtil.cs

示例8: ContainsDelegate

 internal static bool ContainsDelegate(MulticastDelegate source, Delegate d)
 {
   if (null != source && null != d)
   {
     Delegate[] list = source.GetInvocationList();
     if (null != list)
     {
       for (int i = 0; i < list.Length; i++)
       {
         if (list[i].Equals(d))
           return true;
       }
     }
   }
   return false;
 }
開發者ID:austinlaw,項目名稱:rhinocommon,代碼行數:16,代碼來源:hostutils.cs

示例9: FindBuilder

 internal static Delegate FindBuilder(MulticastDelegate mcd)
 {
   if (mcd != null)
   {
     Delegate[] invocationList = mcd.GetInvocationList();
     for (int i = 0; i < invocationList.Length; i++)
     {
       if (invocationList[i].Target is DbCommandBuilder)
       {
         return invocationList[i];
       }
     }
   }
   return null;
 }
開發者ID:rohitlodha,項目名稱:DenverDB,代碼行數:15,代碼來源:SQLiteDataAdapter.cs

示例10: GetDelegatesWithNonTransientTargets

 internal Delegate[] GetDelegatesWithNonTransientTargets(MulticastDelegate mDelegate)
 {
     return mDelegate.GetInvocationList().Where(x => x.Target == null || !CheckTransient(x.Target)).ToArray();
 }
開發者ID:PiotrZierhoffer,項目名稱:Migrant,代碼行數:4,代碼來源:ObjectWriter.cs

示例11: FireEventToDelegates

        /// <summary>
        /// Custom handler for firing a WMI event to a list of delegates. We use
        /// the process thread pool to handle the firing.
        /// </summary>
        /// <param name="md">The MulticastDelegate representing the collection
        /// of targets for the event</param>
        /// <param name="args">The accompanying event arguments</param>
        internal void FireEventToDelegates (MulticastDelegate md, ManagementEventArgs args)
        {
            try 
            {
                if (null != md)
                {
#if USEPOOL
                    Delegate[] delegateList = md.GetInvocationList ();

                    if (null != delegateList)
                    {
                        int numDelegates = delegateList.Length;
                        AutoResetEvent[] waitHandles = new AutoResetEvent [numDelegates];

                        /*
                         * For each target delegate, queue a request to the 
                         * thread pool to handle the POST. We pass as state the 
                         *  1) Target delegate
                         *  2) Event args
                         *  3) AutoResetEvent that the thread should signal to 
                         *     indicate that it is done.
                         */
                        for (int i = 0; i < numDelegates; i++)
                        {
                            waitHandles [i] = new AutoResetEvent (false);
                            ThreadPool.QueueUserWorkItem (
                                    new WaitCallback (this.FireEventToDelegate),
                                    new WmiEventState (delegateList[i], args, waitHandles[i]));
                        }

                        /*
                         * We wait for all the delegates to signal that they are done.
                         * This is because if we return from the IWbemObjectSink callback
                         * before they are all done, it is possible that a delegate will
                         * begin to process the next callback before the current callback
                         * processing is done.
                         */
                        WaitHandle.WaitAll (waitHandles, 10000, true);
                        }
                    }
#endif
                    foreach (Delegate d in md.GetInvocationList())
                    {
                        try 
                        {
                            d.DynamicInvoke (new object [] {this.sender, args});    
                        } 
                        catch
                        {
                        }
                    }
                }
            }
開發者ID:krytht,項目名稱:DotNetReferenceSource,代碼行數:60,代碼來源:ManagementOperationWatcher.cs


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