Example #1
0
        private void Restart()
        {
            // Restarts the program for the current model
            ModelMetadata        modelMetadata        = dependencyInjection.Resolve <ModelMetadata>();
            StartInstanceService startInstanceService = new StartInstanceService();

            startInstanceService.StartInstance(modelMetadata.ModelFilePath);
        }
Example #2
0
        public static void Shutdown(string message, Exception e)
        {
            if (hasShutdown)
            {
                // Shutdown already in progress
                return;
            }

            hasShutdown = true;

            Log.Exception(e, message);

            if (isDispatcherInitialized)
            {
                var dispatcher = GetApplicationDispatcher();
                if (dispatcher.CheckAccess())
                {
                    ShowExceptionDialog(e);
                }
                else
                {
                    dispatcher.Invoke(() => ShowExceptionDialog(e));
                }
            }

            if (Debugger.IsAttached)
            {
                Debugger.Break();
            }

            if (DateTime.Now - StartTime >= MinTimeBeforeAutoRestart)
            {
                StartInstanceService.StartInstance(Environment.CurrentDirectory);
            }

            if (isDispatcherInitialized)
            {
                Application.Current.Shutdown(0);
            }
            else
            {
                throw new Exception($"Unhandled exception {message}", e);
            }
        }