Пример #1
0
    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);
        }
    }
Пример #2
0
    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);
        }
    }