예제 #1
0
        public void Shutdown(bool directShutdown = false)
        {
            Console.TreatControlCAsInput = true;

            // If Config is not set then nothing is and we are already done.
            if (Config == null)
            {
                return;
            }

            lock (_bootInProgressLocker)
            {
                if (directShutdown)
                {
                    Console.Beep(1000, 100);
                    Console.Beep(1000, 100);

                    // Clear out previous input.
                    while (Console.KeyAvailable)
                    {
                        Console.ReadKey(true);
                    }

                    Console.WriteLine();
                    Console.WriteLine("Are you sure you want to shutdown?");
                    Console.WriteLine("Press Y to confirm!");
                    Console.WriteLine();

                    if (Console.ReadKey(true).Key != ConsoleKey.Y)
                    {
                        Console.TreatControlCAsInput = false;
                        Console.WriteLine("Shutdown cancelled.");
                        return;
                    }
                    Console.WriteLine("Shutting down. Please wait...");
                }

                Thread forceThread = new Thread(new ThreadStart(ForceShutdown));
                forceThread.IsBackground = true;
                forceThread.Start();

                CoreManager.ServerCore.OfficalEventFirer.Fire("shutdown", EventPriority.Before, this, EventArgs.Empty);
                CoreManager.ServerCore.OfficalEventFirer.Fire("shutdown", EventPriority.After, this, EventArgs.Empty);

                WebAdminManager.Stop();


                Console.Beep(4000, 100);
                Console.Beep(3500, 100);
                Console.Beep(3000, 100);
                Console.Beep(2500, 100);
                Console.Beep(2000, 100);
                Console.Beep(1500, 100);
                Console.Beep(1000, 100);
            }
        }
예제 #2
0
        public void Shutdown(bool terminate = true)
        {
            lock (_bootInProgressLocker)
            {
                if (ConsoleManager == null)
                {
                    return;
                }

                ConsoleManager.Warning("Core", "Shutting down IHI!");

                if (CoreManager.ServerCore.OfficalEventFirer == null)
                {
                    return;
                }

                IHIEventArgs eventArgs = new IHIEventArgs();
                CoreManager.ServerCore.OfficalEventFirer.Fire("shutdown:before", eventArgs);
                CoreManager.ServerCore.OfficalEventFirer.Fire("shutdown:after", eventArgs);

                if (WebAdminManager == null)
                {
                    return;
                }

                WebAdminManager.Stop();

                Config = null;

                System.Console.Beep(4000, 100);
                System.Console.Beep(3500, 100);
                System.Console.Beep(3000, 100);
                System.Console.Beep(2500, 100);
                System.Console.Beep(2000, 100);
                System.Console.Beep(1500, 100);
                System.Console.Beep(1000, 100);
            }
        }