Exemple #1
0
        public static void Cleanup()
        {
            Log.WriteInfo(nameof(Application), "Exiting...");

            try
            {
                Steam.Instance.IsRunning = false;
                Steam.Instance.Client.Disconnect();
                Steam.Instance.Dispose();
            }
            catch (Exception e)
            {
                ErrorReporter.Notify(nameof(Application), e);
            }

            if (Settings.Current.IRC.Enabled)
            {
                Log.WriteInfo(nameof(Application), "Closing IRC connection...");

                RssReader.Timer.Stop();
                RssReader.Dispose();

                IRC.Instance.Close();

                IrcThread.Join(TimeSpan.FromSeconds(5));
            }

            TaskManager.CancelAllTasks();

            LocalConfig.Save();
        }
        public static void Cleanup()
        {
            Log.WriteInfo(nameof(Application), "Exiting...");

            try
            {
                Steam.Instance.IsRunning = false;
                Steam.Instance.Client.Disconnect();
                Steam.Instance.Dispose();
            }
            catch (Exception e)
            {
                ErrorReporter.Notify(nameof(Application), e);
            }

            if (Settings.Current.IRC.Enabled)
            {
                Log.WriteInfo(nameof(Application), "Closing IRC connection...");

                RssReader.Timer.Stop();
                RssReader.Dispose();

                IRC.Instance.Close();

                IrcThread.Join(TimeSpan.FromSeconds(5));
            }

            TaskManager.CancelAllTasks();

            if (!Settings.IsFullRun)
            {
                LocalConfig.Update("backend.changenumber", Steam.Instance.PICSChanges.PreviousChangeNumber.ToString())
                .GetAwaiter().GetResult();
            }
        }
Exemple #3
0
        public static void Cleanup()
        {
            // If threads is null, app was not yet initialized and there is nothing to cleanup
            if (Threads == null)
            {
                return;
            }

            Log.WriteInfo("Bootstrapper", "Exiting...");

            try
            {
                Steam.Instance.IsRunning = false;
                Steam.Instance.Client.Disconnect();
                Steam.Instance.Dispose();
            }
            catch (Exception e)
            {
                ErrorReporter.Notify("Bootstrapper", e);
            }

            if (Settings.Current.BuiltInHttpServerPort > 0)
            {
                HttpServer.Dispose();
            }

            if (Settings.Current.IRC.Enabled)
            {
                Log.WriteInfo("Bootstrapper", "Closing IRC connection...");

                RssReader.Timer.Stop();
                RssReader.Dispose();

                IRC.Instance.Close();
            }

            Log.WriteInfo("Bootstrapper", "Cancelling {0} tasks...", TaskManager.TasksCount);

            TaskManager.CancelAllTasks();

            foreach (var thread in Threads.Where(thread => thread.ThreadState == ThreadState.Running))
            {
                Log.WriteInfo("Bootstrapper", "Joining thread {0}...", thread.Name);

                thread.Join(TimeSpan.FromSeconds(5));
            }

            Log.WriteInfo("Bootstrapper", "Saving local config...");

            LocalConfig.Save();
        }