Skip to content

Commit bedccd2

Browse files
committed
Async JavascriptBinding - Return null instead of empty object for async Task methods
Resolves #3980
1 parent 870dbb5 commit bedccd2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

CefSharp/Internals/ConcurrentMethodRunnerQueue.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace CefSharp.Internals
1616
/// </summary>
1717
public class ConcurrentMethodRunnerQueue : IMethodRunnerQueue
1818
{
19+
private static Type VoidTaskResultType = Type.GetType("System.Threading.Tasks.VoidTaskResult");
1920
private readonly IJavascriptObjectRepositoryInternal repository;
2021
private CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
2122

@@ -77,10 +78,14 @@ public void Enqueue(MethodInvocation methodInvocation)
7778
{
7879
if (t.Status == TaskStatus.RanToCompletion)
7980
{
80-
//TODO: Use resultTask.GetAwaiter().GetResult() instead
8181
//We use some reflection to get the Result
8282
//If someone has a better way of doing this then please submit a PR
8383
result.Result = resultType.GetProperty("Result").GetValue(resultTask);
84+
85+
if (result.Result != null && result.Result.GetType() == VoidTaskResultType)
86+
{
87+
result.Result = null;
88+
}
8489
}
8590
else
8691
{

0 commit comments

Comments
 (0)