提交 57c75990 编写于 作者: J Jason Malinowski 提交者: GitHub

Merge pull request #14643 from jasonmalinowski/async-lazy-can-block-on-background-thread

Allow AsyncLazy.GetValue to be called on a background thread
......@@ -222,7 +222,11 @@ public override T GetValue(CancellationToken cancellationToken)
StartAsynchronousComputation(newAsynchronousComputation.Value, requestToCompleteSynchronously: request, callerCancellationToken: cancellationToken);
}
return request.Task.WaitAndGetResult(cancellationToken);
// The reason we have synchronous codepaths in AsyncLazy is to support the synchronous requests for syntax trees
// that we may get from the compiler. Thus, it's entirely possible that this will be requested by the compiler or
// an analyzer on the background thread when another part of the IDE is requesting the same tree asynchronously.
// In that case we block the synchronous request on the asynchronous request, since that's better than alternatives.
return request.Task.WaitAndGetResult_CanCallOnBackground(cancellationToken);
}
else
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册