From 386ed86106771205bb93c4f4004a6c72802fb3e0 Mon Sep 17 00:00:00 2001 From: rogeralsing Date: Sun, 12 Apr 2015 15:03:31 +0200 Subject: [PATCH] Hotfix async await when awaiting IO completion port based tasks --- src/core/Akka.Tests/Dispatch/AsyncAwaitSpec.cs | 5 +++-- src/core/Akka/Dispatch/ActorTaskScheduler.cs | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/Akka.Tests/Dispatch/AsyncAwaitSpec.cs b/src/core/Akka.Tests/Dispatch/AsyncAwaitSpec.cs index c88ea5dbff4..eb14022b53c 100644 --- a/src/core/Akka.Tests/Dispatch/AsyncAwaitSpec.cs +++ b/src/core/Akka.Tests/Dispatch/AsyncAwaitSpec.cs @@ -19,9 +19,10 @@ class AsyncActor : ReceiveActor { public AsyncActor() { - Receive(AsyncBehavior.Suspend, async s => + Receive( async s => { await Task.Yield(); + await Task.Delay(TimeSpan.FromMilliseconds(100)); if (s == "stop") { Sender.Tell("done"); @@ -345,7 +346,7 @@ public async Task Actor_should_be_able_to_resume_suspend() asker.Tell("msg #" + i); } - var res = await asker.Ask("stop", TimeSpan.FromSeconds(55555)); + var res = await asker.Ask("stop", TimeSpan.FromSeconds(5)); res.ShouldBe("done"); } } diff --git a/src/core/Akka/Dispatch/ActorTaskScheduler.cs b/src/core/Akka/Dispatch/ActorTaskScheduler.cs index 2fc3707af05..9c76b3967d5 100644 --- a/src/core/Akka/Dispatch/ActorTaskScheduler.cs +++ b/src/core/Akka/Dispatch/ActorTaskScheduler.cs @@ -65,6 +65,7 @@ protected override void QueueTask(Task task) s.Self.Tell(new CompleteTask(s, () => { + SetCurrentState(s.Self,s.Sender,s.Message); TryExecuteTask(task); if (task.IsFaulted) Rethrow(task, null);