/// <summary> /// Enqueue cut task. /// </summary> /// <param name="info">CutterInfo.</param> private void EnqueueTask(CutterInfo info) { CutTask task = new CutTask { Callback = new WaitCallback(CutProc), Args = info, }; _taskQueue.Enqueue(task); _putNotification.Set(); }
/// <summary> /// Run thread pool loop. /// </summary> private void ThreadRun() { while (true) { if (_taskQueue.Count == 0) { _putNotification.WaitOne(); } CutTask task = _taskQueue.Dequeue(); if (task == null) { continue; } task.Callback(task.Args); } }