From ca60b1e24d4c99b45979a8e6fc1458de2e1d76c0 Mon Sep 17 00:00:00 2001 From: Stephan Date: Wed, 5 Oct 2016 15:07:47 +0200 Subject: [PATCH] More BackgroundTaskRunner troubleshooting --- src/Umbraco.Web/Scheduling/BackgroundTaskRunner.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web/Scheduling/BackgroundTaskRunner.cs b/src/Umbraco.Web/Scheduling/BackgroundTaskRunner.cs index acbbdbf710..67c342ee2f 100644 --- a/src/Umbraco.Web/Scheduling/BackgroundTaskRunner.cs +++ b/src/Umbraco.Web/Scheduling/BackgroundTaskRunner.cs @@ -52,7 +52,7 @@ namespace Umbraco.Web.Scheduling private bool _terminating; // ensures we raise that event only once private bool _terminated; // remember we've terminated - private TaskCompletionSource _terminatedSource; // enable awaiting termination + private readonly TaskCompletionSource _terminatedSource = new TaskCompletionSource(); // enable awaiting termination /// /// Initializes a new instance of the class. @@ -201,10 +201,6 @@ namespace Umbraco.Web.Scheduling { lock (_locker) { - if (_terminatedSource == null) - _terminatedSource = new TaskCompletionSource(); - if (_terminated) - _terminatedSource.SetResult(0); return new ThreadingTaskImmutable(_terminatedSource.Task); } } @@ -719,8 +715,7 @@ namespace Umbraco.Web.Scheduling OnEvent(Terminated, "Terminated"); - if (terminatedSource != null) - terminatedSource.SetResult(0); + terminatedSource.SetResult(0); } } }