From e8111e8ac6ea6497dc474f21251cb323f737f261 Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Wed, 18 Jun 2014 21:33:31 +0100 Subject: [PATCH] Restart the process rather than reloading a new AppDomain. --- OpenRA.Game/Support/Program.cs | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/OpenRA.Game/Support/Program.cs b/OpenRA.Game/Support/Program.cs index 1313760448..60b3333ff5 100644 --- a/OpenRA.Game/Support/Program.cs +++ b/OpenRA.Game/Support/Program.cs @@ -111,23 +111,13 @@ namespace OpenRA static RunStatus Run(string[] args) { - if (AppDomain.CurrentDomain.IsDefaultAppDomain()) - { - var name = Assembly.GetEntryAssembly().GetName(); - int retCode; - do - { - var domain = AppDomain.CreateDomain("Game"); - retCode = domain.ExecuteAssemblyByName(name, args); - AppDomain.Unload(domain); - } - while (retCode == (int)RunStatus.Restart); - return RunStatus.Success; - } - Game.Initialize(new Arguments(args)); GC.Collect(); - return Game.Run(); + var status = Game.Run(); + if (status == RunStatus.Restart) + using (var p = Process.GetCurrentProcess()) + Process.Start(Assembly.GetEntryAssembly().Location, p.StartInfo.Arguments); + return status; } } } \ No newline at end of file