From 4392b04ceb62c9c02ca747cac915e67d9ee05bcb Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Mon, 9 Aug 2021 12:28:47 -0500 Subject: [PATCH 1/2] close #3019 - use `Failure` to programmatically cancel `Ask` --- src/core/Akka/Actor/ActorRef.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/core/Akka/Actor/ActorRef.cs b/src/core/Akka/Actor/ActorRef.cs index 19a4ebab5fb..1254d31d777 100644 --- a/src/core/Akka/Actor/ActorRef.cs +++ b/src/core/Akka/Actor/ActorRef.cs @@ -134,6 +134,10 @@ protected override void TellInternal(object message, IActorRef sender) { _result.TrySetResult(t); } + else if (message is Failure f) + { + _result.TrySetException(f.Exception ?? new TaskCanceledException("Task cancelled by actor via Failure message.")); + } else { _result.TrySetException(new ArgumentException( @@ -142,15 +146,6 @@ protected override void TellInternal(object message, IActorRef sender) } } } - - /// - /// TBD - /// - /// TBD - public override void SendSystemMessage(ISystemMessage message) - { - base.SendSystemMessage(message); - } } From 3712855318ce1376a96f67c77163c86ecb5c2306 Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Mon, 9 Aug 2021 13:33:12 -0500 Subject: [PATCH 2/2] added `SendSystemMessage` call back --- src/core/Akka/Actor/ActorRef.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/Akka/Actor/ActorRef.cs b/src/core/Akka/Actor/ActorRef.cs index 1254d31d777..96353c32da9 100644 --- a/src/core/Akka/Actor/ActorRef.cs +++ b/src/core/Akka/Actor/ActorRef.cs @@ -146,6 +146,15 @@ protected override void TellInternal(object message, IActorRef sender) } } } + + /// + /// TBD + /// + /// TBD + public override void SendSystemMessage(ISystemMessage message) + { + base.SendSystemMessage(message); + } }