Exemple #1
0
        public override void Post(SendOrPostCallback d, object state)
        {
            // queue the item and don't wait for its execution
            SendOrPostCallbackItem item = new SendOrPostCallbackItem(d, state, ExecutionType.Post);

            queue.Enqueue(item);
        }
Exemple #2
0
        public override void Send(SendOrPostCallback d, object state)
        {
            SendOrPostCallbackItem item = new SendOrPostCallbackItem(d, state, ExecutionType.Send);

            queue.Enqueue(item);

            // wait for execution
            item.ExecutionCompleteWaitHandle.WaitOne();

            if (item.ExecutedWithException)
            {
                throw item.Exception;
            }
        }
Exemple #3
0
        private void Run()
        {
            while (true)
            {
                bool stop = mStopEvent.WaitOne(0);
                if (stop)
                {
                    break;
                }

                SendOrPostCallbackItem workItem = mQueueConsumer.Dequeue();
                if (workItem != null)
                {
                    workItem.Execute();
                }
            }
        }