public static void Main(string[] args) { MainThread = Thread.CurrentThread.ManagedThreadId; PendingWork = new ConcurrentQueue <Work>(); Thread.CurrentThread.Priority = ThreadPriority.Highest; Settings.Init(); Resources.Init(); Database.Init(); AppServer.Init(); GameServer.Init(); Manager.Init(); ThreadUtils.StartNewThread(ThreadPriority.Lowest, AppServer.Start); ThreadUtils.StartNewThread(ThreadPriority.Lowest, GameServer.Start); AppDomain.CurrentDomain.ProcessExit += new EventHandler(Terminate); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Terminate); while (!Terminating) { while (PendingWork.TryDequeue(out Work work)) { try { work.Request(); work.Callback?.Invoke(); } #if DEBUG catch (Exception e1) #endif #if RELEASE catch #endif { #if DEBUG Print(PrintType.Error, e1.ToString()); #endif try { work.Callback?.Invoke(); } #if DEBUG catch (Exception e2) { Print(PrintType.Error, e2.ToString()); } #endif #if RELEASE catch { } #endif } } Database.Tick(); Manager.Tick(); #if DEBUG Thread.Sleep(2); #endif } Terminate(null, null); }