Is it safe to call the ContinueWith method on a TaskCompletionSource.Task (that has had it's .SetResult called)?

前端 未结 2 2010
旧巷少年郎
旧巷少年郎 2021-02-12 15:36

Is it safe to use the ContinueWith(...) method on a TaskCompletionSource.Task if the TaskCompletionSource.SetResult(...) has already been

相关标签:
2条回答
  • 2021-02-12 16:24

    If the specified task has already completed by the time ContinueWith is called, the synchronous continuation will run on the thread calling ContinueWith. https://msdn.microsoft.com/en-us/library/dd321576(v=vs.110).aspx

    0 讨论(0)
  • 2021-02-12 16:34

    Yes this should be fine, ContinueWith checks if the previous task completed or not, if so it will immediately queue up the continuation.

    0 讨论(0)
提交回复
热议问题