Пример #1
0
        /// <summary>
        ///   Terminates the program gracefully
        /// </summary>
        /// <param name="exitCode">Optional exit code</param>
        /// <param name="exit">Whether to actually exit or just perform cleanup tasks</param>
        internal static void Exit(int exitCode = 0, bool exit = true)
        {
            try {
                Log.WriteLine(LogLevel.Warning, $"exiting with code 0x{exitCode:x8}");

                DesktopKeyboardHook?.Dispose();
                DesktopMouseHook?.Dispose();
                TrayIcon?.Hide();
                Options?.Save();
                HudManager?.Dispose();
                UpdateManager?.Dispose();

#if DEBUG
                Log.WriteLine(LogLevel.Warning, ObjectTracker.ReportActiveObjects());
#endif

                loggerStream.Dispose();
                Log.Streams.Clear();

                GC.WaitForPendingFinalizers();
            } catch (Exception exception) {
                // try to log exceptions
                if (Log.Streams?.Count > 0 && Log.Streams.All(s => s.CanWrite))
                {
                    Log.WriteLine(LogLevel.Error, $"exception caught: {exception}");
                }
            } finally {
                if (exit)
                {
                    Environment.ExitCode = exitCode;
                    System.Windows.Forms.Application.Exit();
                }
            }
        }
Пример #2
0
 public void Shutdown()
 {
     LogEvent.Tool.Info("Shutting down");
     Close();
     dxViewer.Exit();
     dxViewer.Dispose();
     LogEvent.Tool.Info(ObjectTracker.ReportActiveObjects());
 }
 public static void Finish()
 {
     if (ObjectTracker.FindActiveObjects().Count > 0)
     {
         Trace.WriteLine(ObjectTracker.ReportActiveObjects());
     }
     else
     {
         Trace.WriteLine("Zero leaked objects.");
     }
 }
Пример #4
0
        public static void Main()
        {
#if DEBUG
            Configuration.EnableObjectTracking = true;
#endif

            using var app = new TestApplication(headless: false);
            app.Run();
#if DEBUG
            Console.WriteLine(ObjectTracker.ReportActiveObjects());
#endif
        }
Пример #5
0
    public static void Main()
    {
        //try
        //{
        //    // Just safelly test DXCore stuff
        //    TestDXCore();
        //}
        //catch
        //{

        //}

#if DEBUG
        Configuration.EnableObjectTracking = true;
#endif

        using (var app = new TestApplication())
            app.Run();

#if DEBUG
        Console.WriteLine(ObjectTracker.ReportActiveObjects());
#endif
    }