Beispiel #1
0
        public static void Start()
        {
            #if !DEBUG
            try
            #endif
            {
                if (SingleInstanceApplication)
                {
                    solitude = new Solitude("TheMeldingWars." + Name, CommandHandler);

                    if (!solitude.FirstInstance)
                    {
                        return;
                    }
                }


                if (!Common.IsDebugging())
                {
                    string[] args = Environment.GetCommandLineArgs();
                    if (!DataPath.Equals(Path.GetDirectoryName(args[0]), StringComparison.CurrentCultureIgnoreCase))
                    {
                        string here  = args[0];
                        string there = Path.Combine(DataPath, Name + ".exe");

                        if (File.Exists(there))
                        {
                            File.Delete(there);
                        }
                        File.Copy(here, there);
                        Common.Execute(there, Environment.CommandLine);
                        Environment.Exit(0);
                    }
                }
                else
                {
                    Cmd?.Invoke(Environment.GetCommandLineArgs().ToList());
                }

                AppDomain.CurrentDomain.ProcessExit += new EventHandler(ExitHandler);
                Run?.Invoke();
            }
            #if !DEBUG
            catch (Exception ex)
            {
                ErrorHandler(null, new UnhandledExceptionEventArgs(ex, true));
            }
            #endif
        }