static void Main() { Logger.Info("Process starting"); /*DebugLog.AddListener((a, b) => * { * Console.WriteLine("{0} {1} {2}", DateTime.Now, a, b); * }); * * DebugLog.Enabled = true;*/ AppDomain.CurrentDomain.UnhandledException += (sender, e) => { Logger.Fatal("Unhandled exception: " + e.ExceptionObject); Logger.Info("Process exiting"); }; ThreadPool.SetMaxThreads(10, 1); LoadSettings(); if (Settings == null) { Logger.Fatal("Failed to load settings!"); return; } SessionManager = new SessionManager(); RoomManager = new RoomManager(); DelayManager = new DelayManager(); NotificationManager = new NotificationManager(); BatchInserter = new BatchInserter(); Steam = new Steam(); RoomManager.Update(); SessionManager.Start(); _taskScheduler = new TaskScheduler(); _taskScheduler.Add(TimeSpan.FromSeconds(0.5), () => { SessionManager.Update(); RoomManager.Update(); DelayManager.Update(); Steam.Update(); }); _taskScheduler.Add(TimeSpan.FromSeconds(15), () => SessionManager.Ping()); //_taskScheduler.Add(TimeSpan.FromMinutes(1), GC.Collect); _taskScheduler.Add(TimeSpan.FromHours(1), () => { var t = Util.GetTimestamp(DateTime.UtcNow - TimeSpan.FromDays(30)); LoginToken.RemoveOlderThan(t); }); _taskScheduler.Add(TimeSpan.FromSeconds(10), () => { if (!NotificationsDirty) { return; } NotificationManager.InvalidateNotificationCache(); NotificationsDirty = false; }); _taskScheduler.Add(TimeSpan.FromMinutes(2.5), () => { if (Steam.Status == Steam.ConnectionStatus.Connected) { Steam.Bot.PersonaState = EPersonaState.Online; } }); while (true) { _taskScheduler.Run(); Thread.Sleep(10); } }
static void Main() { Logger.Info("Process starting"); /*DebugLog.AddListener((a, b) => { Console.WriteLine("{0} {1} {2}", DateTime.Now, a, b); }); DebugLog.Enabled = true;*/ AppDomain.CurrentDomain.UnhandledException += (sender, e) => { Logger.Fatal("Unhandled exception: " + e.ExceptionObject); Logger.Info("Process exiting"); }; ThreadPool.SetMaxThreads(10, 1); LoadSettings(); if (Settings == null) { Logger.Fatal("Failed to load settings!"); return; } SessionManager = new SessionManager(); RoomManager = new RoomManager(); DelayManager = new DelayManager(); Steam = new Steam(); RoomManager.Update(); SessionManager.Start(); _taskScheduler = new TaskScheduler(); _taskScheduler.Add(TimeSpan.FromSeconds(0.5), () => { SessionManager.Update(); RoomManager.Update(); DelayManager.Update(); Steam.Update(); }); _taskScheduler.Add(TimeSpan.FromSeconds(5), () => SessionManager.Ping()); _taskScheduler.Add(TimeSpan.FromMinutes(1), GC.Collect); _taskScheduler.Add(TimeSpan.FromHours(1), () => { var t = Util.GetTimestamp(DateTime.UtcNow - TimeSpan.FromDays(30)); LoginToken.RemoveOlderThan(t); }); _taskScheduler.Add(TimeSpan.FromMinutes(2.5), () => { if (Steam.Status == Steam.ConnectionStatus.Connected) { Steam.Bot.PersonaState = EPersonaState.Online; } }); while (true) { _taskScheduler.Run(); Thread.Sleep(10); } }