diff --git a/src/Assets/Scripts/Patcher/Patcher.cs b/src/Assets/Scripts/Patcher/Patcher.cs index d613e47d..8985ff25 100644 --- a/src/Assets/Scripts/Patcher/Patcher.cs +++ b/src/Assets/Scripts/Patcher/Patcher.cs @@ -33,6 +33,8 @@ public class Patcher : IDisposable private PatcherStatus _status; + private Thread _thread; + public event Action OnPatcherStarted; public event Action OnPatcherProgress; @@ -73,7 +75,7 @@ public void Start() ResetStatus(PatcherState.Patching); - ThreadPool.QueueUserWorkItem(state => + _thread = new Thread(state => { LogInfo("Invoking OnPatchingStarted event."); Dispatcher.Invoke(InvokeOnPatcherStarted); @@ -102,7 +104,11 @@ public void Start() LogInfo("Invoking OnPatchingFinished event."); Dispatcher.Invoke(InvokeOnPatcherFinished); } - }); + }) + { + IsBackground = true + }; + _thread.Start(); } public void Cancel() @@ -417,7 +423,11 @@ private static void LogWarning(string message) public void Dispose() { - Cancel(); + if (_thread != null && _thread.IsAlive) + { + Debug.LogWarning("Patcher thread wasn't cancelled so it had to be aborted."); + _thread.Abort(); + } } protected virtual void InvokeOnPatcherStarted() diff --git a/src/Assets/Scripts/Patcher/PatcherApplication.cs b/src/Assets/Scripts/Patcher/PatcherApplication.cs index e90cc776..a7fc9ad7 100644 --- a/src/Assets/Scripts/Patcher/PatcherApplication.cs +++ b/src/Assets/Scripts/Patcher/PatcherApplication.cs @@ -139,11 +139,6 @@ protected virtual void OnApplicationQuit() Application.Quit(); }; } - else - { - // HACK: Linux patcher is hanging if Application.Quit is used - Environment.Exit(0); - } } protected virtual void OnDestroy()