internal virtual void QueueWorkItem(WorkItem workItem) { lock(m_WorkItemQueue) { m_WorkItemQueue.Enqueue(workItem); CallQueued.Release(); } }
public void Abort() { CallQueued.Release(Int32.MaxValue); foreach (WorkerThread thread in m_WorkerThreads) { thread.m_ThreadObj.Abort(); } CallQueued.Close(); }
internal override void QueueWorkItem(WorkItem workItem) { CallPriority priority; GenericContext <CallPriority> context = GenericContext <CallPriority> .Current; if (context == null) { priority = Priority;//Read from TLS } else { priority = context.Value; } switch (priority) { case CallPriority.Low: { lock (m_LowPriorityItemQueue) { m_LowPriorityItemQueue.Enqueue(workItem); CallQueued.Release(); return; } } case CallPriority.Normal: { lock (m_NormalPriorityItemQueue) { m_NormalPriorityItemQueue.Enqueue(workItem); CallQueued.Release(); return; } } case CallPriority.High: { lock (m_HighPriorityItemQueue) { m_HighPriorityItemQueue.Enqueue(workItem); CallQueued.Release(); return; } } default: { throw new InvalidOperationException("Unknown priority value: " + priority); } } }
public void Close() { if (CallQueued.SafeWaitHandle.IsClosed) { return; } CallQueued.Release(Int32.MaxValue); foreach (WorkerThread thread in m_WorkerThreads) { thread.Kill(); } CallQueued.Close(); }