/// <summary> /// 启动 /// </summary> public static void Start() { IsRun = true; try { BLog.Write(BLog.LogLevel.INFO, "程序即将启动。"); _bw = new BackgroundWorker(); _bw.WorkerSupportsCancellation = true; _bw.DoWork += bw_DoWork; _bw.RunWorkerAsync(); TaskScanner.Start(); BLog.Write(BLog.LogLevel.INFO, "程序已经启动。"); } catch (Exception ex) { BLog.Write(BLog.LogLevel.FATAL, "程序启动失败。" + ex.ToString()); } }
/// <summary> /// 停止 /// </summary> public static void Stop() { IsRun = false; try { BLog.Write(BLog.LogLevel.INFO, "程序即将停止。"); TaskScanner.Stop(); _bw.CancelAsync(); _bw.Dispose(); foreach (var kvp in _dicTaskers) { kvp.Value.Stop(); } _dicTaskers.Clear(); BLog.Write(BLog.LogLevel.INFO, "程序已经停止。"); } catch (Exception ex) { BLog.Write(BLog.LogLevel.ERROR, "程序停止失败。" + ex.ToString()); } }