Esempio n. 1
0
        /// <summary>
        /// Runs this instance.
        /// </summary>
        internal static void Run(params string[] Args)
        {
            if (Program.Initialized == false)
            {
                Environment.Exit(0);
            }

            if (ExitHandler.Exiting)
            {
                return;
            }

            ExitHandler.Exiting = true;

            var WarningsTask = ExitHandler.SetMaintenance();

            var PlayersTask = Players.SaveAll();
            var ClansTask   = Clans.SaveAll();
            var BattlesTask = Battles.SaveAll();

            Task.WaitAll(WarningsTask, PlayersTask, ClansTask, BattlesTask);

            if (Args.Length > 1)
            {
                if (Args[1] == "--force" || Args[1] == "-f")
                {
                    ExitHandler.DisconnectEveryone().Wait();
                    Environment.Exit(0);
                }
            }

            ExitHandler.WaitTillWarnEnd();
            ExitHandler.DisconnectEveryone().Wait();

            Environment.Exit(0);
        }