Ejemplo n.º 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);
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 3
0
        private void Run()
        {
            while (true)
            {
                bool stop = mStopEvent.WaitOne(0);
                if (stop)
                {
                    break;
                }

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