Calling TaskCompletionSource.SetResult in a non blocking manner

前端 未结 4 2020
夕颜
夕颜 2020-12-03 06:59

I\'ve discovered that TaskCompletionSource.SetResult(); invokes the code awaiting the task before returning. In my case that result in a deadlock.

This

4条回答
  •  暖寄归人
    2020-12-03 07:33

    "My assumption was that the second SendAwaitResponse would execute in a ThreadPool thread but it continues in the thread created for ReceiverRun."

    It depends entirely on what you do within SendAwaitResponse. Asynchrony and concurrency are not the same thing.

    Check out: C# 5 Async/Await - is it *concurrent*?

提交回复
热议问题