dotnet / dotnet/interactive-window
Calling interactive window methods from non-UI threads may lead to deadlock
- Dominant language
- C#
- Stars
- 75
- Forks
- 43
- PR merge metrics
- No merged PRs in 30d
Description
When standard UI thread loop is replaced with `JoinableTaskFactory` job, `Dispatcher.Invoke` is blocked until job is completed. This may end up in a deadlock if calling code has switched from UI thread to background using `СonfigureAwait(false)` or any other custom awaiter.
Issue can be easily got around by calling all interactive window methods from UI thread, but it eliminates the advantage of calling `IInteractiveWindow.Write` from background thread. Maybe this method can use `BeginInvoke` instead.
Scenario: User inputs some command into interactive window. InteractiveEvaluator.ExecuteCodeAsync switches to background thread and waits until command is completed. Command produces some output which we have to print to user while it is coming. If command produces too much output and for each of it we have to create a task in Dispatcher, we get too many of them which is noticeable by user.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.