public override void Post(SendOrPostCallback d, object state)
 {
     // queue the item and don't wait for its execution. This is risky because
     // an unhandled exception will terminate the STA thread. Use with caution.
     SendOrPostCallbackItem item = new SendOrPostCallbackItem(d, state,
                                       ExecutionType.Post);
     mQueue.Enqueue(item);
 }
Exemplo n.º 2
0
        public override void Post(SendOrPostCallback d, object state)
        {
            // queue the item and don't wait for its execution. This is risky because
            // an unhandled exception will terminate the STA thread. Use with caution.
            SendOrPostCallbackItem item = new SendOrPostCallbackItem(d, state,
                                                                     ExecutionType.Post);

            mQueue.Enqueue(item);
        }
        public override void Send(SendOrPostCallback d, object state)
        {
            // create an item for execution
            SendOrPostCallbackItem item = new SendOrPostCallbackItem(d, state,
                                              ExecutionType.Send);
            // queue the item
            mQueue.Enqueue(item);
            // wait for the item execution to end
            item.ExecutionCompleteWaitHandle.WaitOne();

            // if there was an exception, throw it on the caller thread, not the
            // sta thread.
            if (item.ExecutedWithException)
                throw item.Exception;
        }
Exemplo n.º 4
0
        private void Run()
        {
            while (true)
            {
                bool stop = mStopEvent.WaitOne(0);
                if (stop)
                {
                    break;
                }

                SendOrPostCallbackItem workItem = mQueueConsumer.Dequeue();
                if (workItem != null)
                {
                    workItem.Execute();
                }
            }
        }
Exemplo n.º 5
0
        public override void Send(SendOrPostCallback d, object state)
        {
            // create an item for execution
            SendOrPostCallbackItem item = new SendOrPostCallbackItem(d, state,
                                                                     ExecutionType.Send);

            // queue the item
            mQueue.Enqueue(item);
            // wait for the item execution to end
            item.ExecutionCompleteWaitHandle.WaitOne();

            // if there was an exception, throw it on the caller thread, not the
            // sta thread.
            if (item.ExecutedWithException)
            {
                throw item.Exception;
            }
        }