Пример #1
0
        public void OnTimer(Object state)
        {
            lock (this)
            {
                if (workItems.Count == 0)
                {
                    return;
                }

                if (activeThreads < MaxThreads)
                {
                    WorkThread.AddWorker(this);
                }
            }
        }
Пример #2
0
 public bool QueueUserWorkItem(WaitCallback callback, Object state)
 {
     if (null == callback)
     {
         return(false);
     }
     lock (this)
     {
         workItems.Push(new WorkItem(callback, state));
         if (activeThreads == 0)
         {
             WorkThread.AddWorker(this);
         }
         return(true);
     }
 }