Example #1
0
 internal virtual void QueueWorkItem(WorkItem workItem)
 {
     lock(m_WorkItemQueue)
      {
     m_WorkItemQueue.Enqueue(workItem);
     CallQueued.Release();
      }
 }
Example #2
0
        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);
            }
            }
        }
Example #4
0
        public void Close()
        {
            if (CallQueued.SafeWaitHandle.IsClosed)
            {
                return;
            }
            CallQueued.Release(Int32.MaxValue);

            foreach (WorkerThread thread in m_WorkerThreads)
            {
                thread.Kill();
            }
            CallQueued.Close();
        }