예제 #1
0
        static void Main()
        {
            try
            {
                // mutex to prevent multiple instance of application running
                using var mutex = new Mutex(true, MutexName);
                if (!mutex.WaitOne(MutexTimeout))
                {
                    MessageBox.Show(MessagesText.SingleInstanceError, MessagesText.AppName,
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                // install services
                RegisterLogger();
                RegisterServices();

                // find vscode
                var path = Container.GetRequiredService <IPathManager>();
                if (!path.IsVscodeInstalled)
                {
                    Log.Debug("Visual Studio Code not found");
                    MessageBox.Show(MessagesText.VSCodeNotInstalled, MessagesText.AppName,
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                // find mingw
                if (!path.IsKfMingwInstalled)
                {
                    Log.Debug("KF-MinGW not found");
                    MessageBox.Show(MessagesText.KFmingwNotInstalled, MessagesText.AppName,
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                // enable TLS
                Log.Debug("Enabling TLS support");
                NetworkHelpers.EnableTls();

                // bootstrapper
                Log.Debug("Bootstrapping application");
                ApplicationConfiguration.Initialize();
                Application.Run(Container.GetRequiredService <KFlearningApplicationContext>());
            }
            catch (Exception e)
            {
                Log.Fatal("Application shutdown unexpectedly", e);
                MessageBox.Show(MessagesText.FatalShutdown, MessagesText.AppName,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                AppExitHandler();
                Log.CloseAndFlush();
            }
        }