private static void Run() { try { Windows.ConsoleHandler.Register(Exit); BuildEventPath <Per10SecondEvent>("呼吸表示活着", LogEnum.None, path: message => { NTMinerRegistry.SetNoDevFeeActiveOn(DateTime.Now); NoDevFee.NoDevFeeUtil.StartAsync(); }, typeof(VirtualRoot)); BuildEventPath <Per24HourEvent>("周期清理日志文件", LogEnum.None, path: message => { #region try { List <string> toRemoves = new List <string>(); foreach (var file in Directory.GetFiles(Logger.DirFullPath)) { FileInfo fileInfo = new FileInfo(file); if (fileInfo.LastWriteTime.AddDays(2) < DateTime.Now) { toRemoves.Add(file); } } if (toRemoves.Count == 0) { Logger.OkDebugLine("没有过期的Log"); } else { foreach (var item in toRemoves) { File.Delete(item); } Logger.OkDebugLine("过期Log清理完成"); } } catch (Exception e) { Logger.ErrorDebugLine(e); } #endregion }, typeof(VirtualRoot)); _waitHandle.WaitOne(); Exit(); } catch (Exception e) { Logger.ErrorDebugLine(e); } finally { Exit(); } }
private static void Run() { try { Windows.ConsoleHandler.Register(Exit); BuildEventPath <Per10SecondEvent>("呼吸表示活着", LogEnum.None, path: message => { NTMinerRegistry.SetNoDevFeeActiveOn(DateTime.Now); }, typeof(VirtualRoot)); _waitHandle.WaitOne(); Exit(); } catch (Exception e) { Logger.ErrorDebugLine(e); } finally { Exit(); } }