public void OnTimer(Object state) { lock (this) { if (workItems.Count == 0) { return; } if (activeThreads < MaxThreads) { WorkThread.AddWorker(this); } } }
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); } }