Task chaining without TaskCompletionSource?

前端 未结 3 824
故里飘歌
故里飘歌 2021-01-05 12:53

I\'m converting some async/await code to chained tasks, so I can use it in the released framework. The await code looks like this

public async Task

        
3条回答
  •  难免孤独
    2021-01-05 13:18

    I think that's pretty much the only way to accomplish what you want. Chaining disparate Tasks together isn't supported by the continuation APIs, so you have to resort to using a TaskCompletionSource like you have to coordinate the work.

    I don't have the Async CTP installed on this machine, but why don't you take a look at the code with a decompiler (or ILDASM if you know how to read IL) to see what it's doing. I bet it does something very similar to your TCS code under the covers.

提交回复
热议问题