From 1fa466809e8c00fd829490107e42dc7847bfcae1 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 23 Aug 2021 18:48:19 +0200 Subject: [PATCH] Fix race condition in TimerUpdateTrigger stop --- RGB.NET.Core/Update/TimerUpdateTrigger.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/RGB.NET.Core/Update/TimerUpdateTrigger.cs b/RGB.NET.Core/Update/TimerUpdateTrigger.cs index 98a7237..6c10753 100644 --- a/RGB.NET.Core/Update/TimerUpdateTrigger.cs +++ b/RGB.NET.Core/Update/TimerUpdateTrigger.cs @@ -92,10 +92,20 @@ namespace RGB.NET.Core if (UpdateTask != null) { UpdateTokenSource?.Cancel(); - // ReSharper disable once MethodSupportsCancellation - UpdateTask.Wait(); - UpdateTask.Dispose(); - UpdateTask = null; + try + { + // ReSharper disable once MethodSupportsCancellation + UpdateTask.Wait(); + } + catch (AggregateException) + { + // ignored + } + finally + { + UpdateTask.Dispose(); + UpdateTask = null; + } } } }