From fb5d36b7075ea5b98ea7fecd8d41183de4471637 Mon Sep 17 00:00:00 2001 From: Justin LeFebvre Date: Fri, 23 Sep 2022 14:51:57 -0400 Subject: [PATCH] We don't want to log if either the task OR the inner delay task are canceled (#1758) --- src/Proto.Actor/Utils/TaskFactory.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Proto.Actor/Utils/TaskFactory.cs b/src/Proto.Actor/Utils/TaskFactory.cs index 7a5416befa..6cbe5f80b4 100644 --- a/src/Proto.Actor/Utils/TaskFactory.cs +++ b/src/Proto.Actor/Utils/TaskFactory.cs @@ -24,15 +24,13 @@ public static class SafeTask /// public static async Task Run(Func body, CancellationToken cancellationToken = default, [CallerMemberName] string name = "") { - Task? t = null; try { - t = Task.Run(body, cancellationToken); - await t; + await Task.Run(body, cancellationToken); } - catch (TaskCanceledException e) when (e.Task == t) + catch (TaskCanceledException) { - //pass. do not log if our own task was cancelled + // Pass. Do not log when the task is canceled. } catch (Exception x) {