From eb1f22902bbe3fd4def54477702ebc709ffb7242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6llner?= Date: Sun, 25 Aug 2019 22:29:24 +0200 Subject: [PATCH] Troubleshooting --- Capnp.Net.Runtime/Rpc/Impatient.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Capnp.Net.Runtime/Rpc/Impatient.cs b/Capnp.Net.Runtime/Rpc/Impatient.cs index bc497fa..42265dd 100644 --- a/Capnp.Net.Runtime/Rpc/Impatient.cs +++ b/Capnp.Net.Runtime/Rpc/Impatient.cs @@ -45,8 +45,19 @@ namespace Capnp.Rpc if (rtask.IsCompleted) { // Force .NET to create a new Task instance - var stask = rtask; - rtask = new Task(() => stask.Result); + if (rtask.IsCanceled) + { + rtask = Task.FromCanceled(new CancellationToken(true)); + } + else if (rtask.IsFaulted) + { + rtask = Task.FromException(rtask.Exception.InnerException); + } + else + { + rtask = Task.FromResult(rtask.Result); + } + _taskTable.Add(rtask, promise); } else