mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-20 23:54:19 +01:00
fix: wait for services to unload in framework destroy
This commit is contained in:
parent
48611dcb74
commit
01efbf358a
2 changed files with 16 additions and 4 deletions
|
|
@ -492,10 +492,7 @@ public sealed class Framework : IDisposable, IServiceType
|
||||||
Log.Information("Framework::Destroy!");
|
Log.Information("Framework::Destroy!");
|
||||||
Service<Dalamud>.Get().Unload();
|
Service<Dalamud>.Get().Unload();
|
||||||
this.RunPendingTickTasks();
|
this.RunPendingTickTasks();
|
||||||
|
ServiceManager.WaitForServiceUnload();
|
||||||
// why did we do this here? EntryPoint also does it when the signal is set, what sense does that make
|
|
||||||
// we should definitely wait for pending tick tasks though
|
|
||||||
// ServiceManager.UnloadAllServices();
|
|
||||||
Log.Information("Framework::Destroy OK!");
|
Log.Information("Framework::Destroy OK!");
|
||||||
|
|
||||||
return this.destroyHook.OriginalDisposeSafe(framework);
|
return this.destroyHook.OriginalDisposeSafe(framework);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Dalamud.Configuration.Internal;
|
using Dalamud.Configuration.Internal;
|
||||||
|
|
@ -36,6 +37,8 @@ internal static class ServiceManager
|
||||||
|
|
||||||
private static readonly List<Type> LoadedServices = new();
|
private static readonly List<Type> LoadedServices = new();
|
||||||
|
|
||||||
|
private static ManualResetEvent unloadResetEvent = new(false);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Kinds of services.
|
/// Kinds of services.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -285,6 +288,8 @@ internal static class ServiceManager
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unloadResetEvent.Reset();
|
||||||
|
|
||||||
var dependencyServicesMap = new Dictionary<Type, List<Type>>();
|
var dependencyServicesMap = new Dictionary<Type, List<Type>>();
|
||||||
var allToUnload = new HashSet<Type>();
|
var allToUnload = new HashSet<Type>();
|
||||||
var unloadOrder = new List<Type>();
|
var unloadOrder = new List<Type>();
|
||||||
|
|
@ -351,6 +356,16 @@ internal static class ServiceManager
|
||||||
{
|
{
|
||||||
LoadedServices.Clear();
|
LoadedServices.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unloadResetEvent.Set();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wait until all services have been unloaded.
|
||||||
|
/// </summary>
|
||||||
|
public static void WaitForServiceUnload()
|
||||||
|
{
|
||||||
|
unloadResetEvent.WaitOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue