예제 #1
0
        static void Main(string[] args)
        {
            DesignMode = false;             // The designer doesn't call Main()

            CommandLineArgs = new CommandLineArgs(args);

            try
            {
                DpiUtil.ConfigureProcess();
            }
            catch
            {
            }

            MonoSpaceFont = new FontEx
            {
                Font   = new Font("Courier New", DpiUtil.ScaleIntX(13), GraphicsUnit.Pixel),
                Width  = DpiUtil.ScaleIntX(8),
                Height = DpiUtil.ScaleIntY(16)
            };

            NativeMethods.EnableDebugPrivileges();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            Settings = SettingsSerializer.Load();
            Logger   = new GuiLogger();

#if !DEBUG
            try
            {
#endif
            using (var coreFunctions = new CoreFunctionsManager())
            {
                RemoteProcess = new RemoteProcess(coreFunctions);

                MainForm = new MainForm();

                Application.Run(MainForm);

                RemoteProcess.Dispose();
            }
#if !DEBUG
        }

        catch (Exception ex)
        {
            ShowException(ex);
        }
#endif

            SettingsSerializer.Save(Settings);
        }
예제 #2
0
        private async void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Stop the update timer
            processUpdateTimer.Stop();

            // and cancel all running tasks.
            if (loadSymbolsTask != null || updateProcessInformationsTask != null)
            {
                e.Cancel = true;

                Hide();

                if (loadSymbolsTask != null)
                {
                    loadSymbolsTaskToken.Cancel();

                    try
                    {
                        await loadSymbolsTask;
                    }
                    catch
                    {
                    }

                    loadSymbolsTask = null;
                }

                if (updateProcessInformationsTask != null)
                {
                    try
                    {
                        await updateProcessInformationsTask;
                    }
                    catch
                    {
                    }

                    updateProcessInformationsTask = null;
                }

                Close();
            }

            remoteProcess.Dispose();
        }
예제 #3
0
        static void Main(string[] args)
        {
            DesignMode = false;             // The designer doesn't call Main()

            CommandLineArgs = new CommandLineArgs(args);

            try
            {
                DpiUtil.ConfigureProcess();
                DpiUtil.TrySetDpiFromCurrentDesktop();
            }
            catch
            {
                // ignored
            }

            MonoSpaceFont = new FontEx
            {
                Font   = new Font("Courier New", DpiUtil.ScaleIntX(13), GraphicsUnit.Pixel),
                Width  = DpiUtil.ScaleIntX(8),
                Height = DpiUtil.ScaleIntY(16)
            };

            NativeMethods.EnableDebugPrivileges();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            Settings = SettingsSerializer.Load();
            Logger   = new GuiLogger();

            if (!NativeMethods.IsUnix() && Settings.RunAsAdmin && !WinUtil.IsAdministrator)
            {
                WinUtil.RunElevated(Process.GetCurrentProcess().MainModule?.FileName, args.Length > 0 ? string.Join(" ", args) : null);
                return;
            }

#if !DEBUG
            try
            {
#endif
            using (var coreFunctions = new CoreFunctionsManager())
            {
                RemoteProcess = new RemoteProcess(coreFunctions);

                MainForm = new MainForm();

                Application.Run(MainForm);

                RemoteProcess.Dispose();
            }
#if !DEBUG
        }

        catch (Exception ex)
        {
            ShowException(ex);
        }
#endif

            SettingsSerializer.Save(Settings);
        }