当前位置: 首页>>代码示例>>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;未经允许,请勿转载。