When to use TaskEx.Run vs. TaskEx.RunEx

后端 未结 3 1108
遥遥无期
遥遥无期 2021-02-06 03:00

I\'m trying to understand when to use TaskEx.Run. I have provided two code sample i wrote below that produce the same result. What i fail to see is why i would ta

3条回答
  •  长情又很酷
    2021-02-06 03:32

    The difference between your two DoWork() methods is that the first one (that uses TaskEx.RunEx()) is not asynchronous at all. It executes fully synchronously, starts the other task on another thread, and immediately returns a completed Task. If you awaited or Wait()ed on that task, it wouldn't wait until the internal task is completed.

提交回复
热议问题