Merge pull request #231 from DarthAffe/Core/UpdateTriggerCancel

Fix race condition in TimerUpdateTrigger stop
This commit is contained in:
Robert Beekman authored and GitHub committed 2021-09-03 20:40:14 +02:00
commit 3074a2b7bf
1 file changed
+10
+10
View File
@@ -92,13 +92,23 @@ namespace RGB.NET.Core
if (UpdateTask != null) if (UpdateTask != null)
{ {
UpdateTokenSource?.Cancel(); UpdateTokenSource?.Cancel();
try
{
// ReSharper disable once MethodSupportsCancellation // ReSharper disable once MethodSupportsCancellation
UpdateTask.Wait(); UpdateTask.Wait();
}
catch (AggregateException)
{
// ignored
}
finally
{
UpdateTask.Dispose(); UpdateTask.Dispose();
UpdateTask = null; UpdateTask = null;
} }
} }
} }
}
private void UpdateLoop() private void UpdateLoop()
{ {