-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid async deadlock in InteractiveHost... #7775
Conversation
The scheduler returned by TaskScheduler.FromCurrentSynchronizationContext does not allow concurrency (meaning all Tasks within a submission were being inlined). This would nearly always result in a deadlock if you kicked off a child Task and attempted to continue within the same submission. We can instead use the Winforms Dispatcher, which will invoke the parent Task on the "UI" thread but allow child Tasks to use the ThreadPool.
FYI @dotnet/roslyn-interactive |
@@ -443,7 +443,7 @@ internal new Task<ScriptState<T>> ContinueAsync(ScriptState previousState, Cance | |||
|
|||
private async Task<ScriptState<T>> RunSubmissionsAsync(ScriptExecutionState executionState, ImmutableArray<Func<object[], Task>> precedingExecutors, Func<object[], Task> currentExecutor, CancellationToken cancellationToken) | |||
{ | |||
var result = await executionState.RunSubmissionsAsync<T>(precedingExecutors, currentExecutor, cancellationToken).ConfigureAwait(continueOnCapturedContext: true); | |||
var result = await executionState.RunSubmissionsAsync<T>(precedingExecutors, currentExecutor, cancellationToken).ConfigureAwait(continueOnCapturedContext: false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not strictly necessary, but I can't imagine why we'd want to continue inline, and there's no comment. It seemed safer to change this to false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @tmat
No objections. :) |
865e056
to
83f21ab
Compare
Avoid async deadlock in InteractiveHost...
The scheduler returned by TaskScheduler.FromCurrentSynchronizationContext
does not allow concurrency (meaning all Tasks within a submission were being
inlined). This would nearly always result in a deadlock if you kicked off a
child Task and attempted to continue within the same submission.
We can instead use the Winforms Dispatcher, which will invoke the parent
Task on the "UI" thread but allow child Tasks to use the ThreadPool.
Fixes #7280