示例#1
0
        public IAsyncResult BeginInvoke(Delegate method, object[] args)
        {
            if (method == null) throw new ArgumentNullException();

            var invoke = new MessageLoopInvoke(method, args ?? new object[0]);

            invokes.Enqueue(invoke);

            return invoke;
        }
示例#2
0
        public object Invoke(Delegate method, object[] args)
        {
            if (method == null) throw new ArgumentNullException();

            var invoke = new MessageLoopInvoke(method, args ?? new object[0]);
            invokes.Enqueue(invoke);

            invoke.WaitHandle.WaitOne();

            if (invoke.Exception != null) throw new MessageLoopException(invoke.Exception);

            return invoke.Result;
        }