private static void ExploreInBackground() { Thread.Sleep(toWait); toWait = 10; PathExplorer last = null; while (!stopExploration) { PathExplorer next = null; lock (waiting) { if (waiting.Count > 0) next = waiting.Dequeue(); else explorerThread = null; // we want to call these notifications after we've processed the above // logic, so that the last PathExplorer's NotifyDone gets called after // explorerThread is null so that IsWorking is false. if (last != null && last.OnExplorationDone != null) { last.NotifyProgress(null, 0, 0); last.NotifyDone(last.pathModel.Path); } } if (next != null) next.BackgroundRun(); else break; last = next; } }
private static void ExploreInBackground() { Thread.Sleep(toWait); toWait = 10; PathExplorer last = null; while (!stopExploration) { PathExplorer next = null; if (contextUpdating) { Thread.Sleep(100); continue; } lock (waiting) { if (waiting.Count > 0) { next = waiting.Dequeue(); } else { explorerThread = null; } // we want to call these notifications after we've processed the above // logic, so that the last PathExplorer's NotifyDone gets called after // explorerThread is null so that IsWorking is false. if (last != null && last.OnExplorationDone != null) { last.NotifyProgress(null, 0, 0); last.NotifyDone(last.pathModel.Path); } } if (next != null) { next.BackgroundRun(); } else { PluginBase.RunAsync(() => { EventManager.DispatchEvent(last, new DataEvent(EventType.Command, "ASCompletion.PathExplorerFinished", null)); }); break; } last = next; } }