We use TaskCompletionSource for callbacks from Rust threads, but resolving a task completion source in a non-.NET thread and await/continue-with in the same thread it was started in can have deadlock issues in certain situations. Setting TaskCreationOptions.RunContinuationsAsynchronously forces the task to schedule its continuation instead of running inline in same blocking thread. We now set this on every completion source callback used by Rust.
The test suite cannot easily replicate this because it is top level, but this was tested against the replication in #248.
What was changed
We use
TaskCompletionSource
for callbacks from Rust threads, but resolving a task completion source in a non-.NET thread and await/continue-with in the same thread it was started in can have deadlock issues in certain situations. SettingTaskCreationOptions.RunContinuationsAsynchronously
forces the task to schedule its continuation instead of running inline in same blocking thread. We now set this on every completion source callback used by Rust.The test suite cannot easily replicate this because it is top level, but this was tested against the replication in #248.
Checklist