public static void Invoke <TDelegate>(TDelegate @delegate, params object[] args) where TDelegate : class { if (@delegate == null) { throw new ArgumentNullException("delegate"); } ParallelInvokeContext <TDelegate> context = new ParallelInvokeContext <TDelegate>(args); lock (context) { foreach (Delegate invocationDelegate in ((Delegate)(object)@delegate).GetInvocationList()) { context.QueueInvoke(invocationDelegate); } Monitor.Wait(context); } }
public static void Invoke(TDelegate @delegate, params object[] args) { if (@delegate == null) { throw new ArgumentNullException("delegate"); } // ToDo: add some argument checking (number and types of arguments) ParallelInvokeContext context = new ParallelInvokeContext(args); lock (context) { foreach (Delegate invocationDelegate in ((Delegate)(object)@delegate).GetInvocationList()) { context.QueueInvoke(invocationDelegate); } Monitor.Wait(context); } }