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); }
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; } }
private void Run() { while (true) { bool stop = mStopEvent.WaitOne(0); if (stop) { break; } SendOrPostCallbackItem workItem = mQueueConsumer.Dequeue(); if (workItem != null) { workItem.Execute(); } } }