diff --git a/Core/Addon/AddonReader.cs b/Core/Addon/AddonReader.cs index fa8e0510..39c32a12 100644 --- a/Core/Addon/AddonReader.cs +++ b/Core/Addon/AddonReader.cs @@ -11,7 +11,7 @@ namespace Core; public sealed class AddonReader : IAddonReader { private readonly IAddonDataProvider reader; - private readonly AutoResetEvent resetEvent; + private readonly ManualResetEventSlim resetEvent; private readonly PlayerReader playerReader; private readonly CreatureDB creatureDb; @@ -33,7 +33,7 @@ public sealed class AddonReader : IAddonReader public double AvgUpdateLatency { private set; get; } public AddonReader(IAddonDataProvider reader, - PlayerReader playerReader, AutoResetEvent resetEvent, + PlayerReader playerReader, ManualResetEventSlim resetEvent, CreatureDB creatureDb, CombatLog combatLog, DataFrame[] frames, diff --git a/Core/DependencyInjection.cs b/Core/DependencyInjection.cs index a05d1353..0c69ef95 100644 --- a/Core/DependencyInjection.cs +++ b/Core/DependencyInjection.cs @@ -198,7 +198,7 @@ public static IServiceCollection AddCoreNormal( public static IServiceCollection AddCoreBase(this IServiceCollection s) { - s.AddSingleton(x => new(false)); + s.AddSingleton(x => new(false)); s.AddSingleton(); s.AddSingleton(); diff --git a/Core/GoalsComponent/Wait.cs b/Core/GoalsComponent/Wait.cs index 0ee98a17..3956b722 100644 --- a/Core/GoalsComponent/Wait.cs +++ b/Core/GoalsComponent/Wait.cs @@ -7,10 +7,10 @@ namespace Core; public sealed class Wait { - private readonly AutoResetEvent globalTime; + private readonly ManualResetEventSlim globalTime; private readonly CancellationToken token; - public Wait(AutoResetEvent globalTime, CancellationTokenSource cts) + public Wait(ManualResetEventSlim globalTime, CancellationTokenSource cts) { this.globalTime = globalTime; this.token = cts.Token; @@ -18,12 +18,20 @@ public Wait(AutoResetEvent globalTime, CancellationTokenSource cts) public void Update() { - globalTime.WaitOne(); + globalTime.Wait(); + globalTime.Reset(); } - public bool Update(int timeout) + public bool Update(int timeoutMs) { - return globalTime.WaitOne(timeout); + bool result = globalTime.Wait(timeoutMs); + if (!result) + { + return result; + } + + globalTime.Reset(); + return result; } public void Fixed(int durationMs)