protected override void OnDoWork(DoWorkEventArgs e) { WorkerSupportsCancellation = true; this.WorkerReportsProgress = true; base.OnDoWork(e); _stepInProgress.Clear(); _threadPool = new ThreadPool(ThreadCounts, ThreadCounts); if (e.Argument is Step[]) { var steps = (Step[])e.Argument; steps.ForEach(FindSolution); } else { FindSolution(e.Argument); } do { Thread.Sleep(3000); ClearFinished(); } while (_stepInProgress.Count > 0); _threadPool.Close(); }
protected override void OnEndBuild() { do { Thread.Sleep(3000); ClearFinished(); } while (StepInProgress.Count > 0); _threadPool.Close(); }
/// <summary> /// Closes the AppDomain wide ManagedIOCP ThreadPool /// used by async object execution /// </summary> public static void Close() { lock (typeof(async)) { if (defaultThreadPool != null) { defaultThreadPool.Close(); defaultThreadPool = null; } } }