Beispiel #1
0
            public void Send(SendOrPostCallback d, object state)
            {
                if (d == null)
                {
                    throw new ArgumentNullException("d");
                }

                if (!this)
                {
                    throw new ObjectDisposedException(GetType().Name);
                }

                if (_mainThreadContext == SynchronizationContext.Current)
                {
                    d.Invoke(state);
                }
                else
                {
                    using (var asyncResult = new InvokeResult(d, state))
                    {
                        lock (_actionQueue)
                        {
                            _actionQueue.Enqueue(asyncResult);
                        }

                        asyncResult.Wait();
                    }
                }
            }