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); } }
private void CreateThread() { WorkThread worker = new WorkThread(this); workers.Add(worker); Thread thread = new Thread(new ThreadStart(worker.Start)); thread.Name = "WT #" + workers.Count; thread.IsBackground = true; worker.Thread = thread; thread.Start(); }
public WorkerThreadSynchronizationContext(WorkThread workThread) { _workThread = Verify.ArgumentNotNull(workThread, "workerThread"); }