public void Process(ExecutionQueueItem item) { if (Running) { // Remote side called us, we called back, and now they're calling back again. Process this request synchronously so we don't hang _commandDispatcher(() => { item.Process(); }); } else { Enqueue(item); item.Wait(); } }
private void ExecutionThread() { while (!_shouldShutDown) { ExecutionQueueItem curItem = null; lock (_items) { if (_items.Count > 0) { curItem = _items[0]; _items.RemoveAt(0); } } if (curItem != null) { try { _running = true; try { _commandDispatcher(() => curItem.Process()); } finally { _running = false; } while (_aborting) { // wait for abort thread to complete ; } } catch (ThreadAbortException) { Thread.ResetAbort(); } curItem.Complete(); } else { _event.WaitOne(); } } }