diff --git a/CefSharp/Internals/ConcurrentMethodRunnerQueue.cs b/CefSharp/Internals/ConcurrentMethodRunnerQueue.cs index 3f87b951de..5e957361b9 100644 --- a/CefSharp/Internals/ConcurrentMethodRunnerQueue.cs +++ b/CefSharp/Internals/ConcurrentMethodRunnerQueue.cs @@ -16,6 +16,7 @@ namespace CefSharp.Internals /// public class ConcurrentMethodRunnerQueue : IMethodRunnerQueue { + private static Type VoidTaskResultType = Type.GetType("System.Threading.Tasks.VoidTaskResult"); private readonly IJavascriptObjectRepositoryInternal repository; private CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); @@ -77,10 +78,14 @@ public void Enqueue(MethodInvocation methodInvocation) { if (t.Status == TaskStatus.RanToCompletion) { - //TODO: Use resultTask.GetAwaiter().GetResult() instead //We use some reflection to get the Result //If someone has a better way of doing this then please submit a PR result.Result = resultType.GetProperty("Result").GetValue(resultTask); + + if (result.Result != null && result.Result.GetType() == VoidTaskResultType) + { + result.Result = null; + } } else {