Is it possible to force the Task returned back from Observable.ToTask() to run continuations asynchronously? #2057
Unanswered
fedeAlterio
asked this question in
Q&A
Replies: 1 comment 1 reply
-
There is a |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Consider this snippet:
Since
.ToTask()
uses internally aTaskCompletionSource
, and the parameterTaskCreationOptions.RunContinuationsAsynchronously
is not specified, the task continuations are executed synchronously (at least in 99% of the cases) on the thread that callsOnNext()
. To fix this issue we can just add aTask.Yield()
after the.ToTask(
), in that way:What do you suggest in this scenario? Why not to expose the TaskCreationOptions with another overload of the
.ToTask()
extension method?Thank you!
Beta Was this translation helpful? Give feedback.
All reactions