public void Stop() { TODO.Clear(); TODO = null; foreach (string path in WATCHER.Keys) { WATCHER[path].EnableRaisingEvents = false; WATCHER[path].Dispose(); WATCHER[path] = null; } WATCHER.Clear(); WATCHER = null; foreach (Task task in TASKS.Keys) { try { TASKS[task].Cancel(); //task.Wait(); TASKS[task].Dispose(); } catch (AggregateException ex) { Console.WriteLine("Task cancel failed :( {0}", ex.InnerExceptions[0].Message); } } TASKS.Clear(); TASKS = null; }
public void Stop() { _logger.LogInformation("otf stop request."); TODO.CollectionChanged -= Source_CollectionChanged; TODO.Clear(); fsBag.Clear(); foreach (string path in WATCHER.Keys) { WATCHER[path].EnableRaisingEvents = false; WATCHER[path].Dispose(); WATCHER[path] = null; } WATCHER.Clear(); WATCHER = null; foreach (Task task in TASKS.Keys) { try { TASKS[task].Cancel(); //task.Wait(); TASKS[task].Dispose(); } catch (AggregateException ex) { _logger.LogError("Task cancel failed :( {0}", ex.InnerExceptions[0].Message); } } TASKS.Clear(); TASKS = null; Running = false; _logger.LogInformation("otf stop."); }