How to track if an async/awaitable task is running

后端 未结 3 1648
执笔经年
执笔经年 2020-12-17 18:14

I\'m trying to transition from the Event-based Asynchronous Pattern where I tracked running methods using unique id\'s and the asynoperationmanager.
As this has now bee

3条回答
  •  醉梦人生
    2020-12-17 18:32

    async/await itself is intended to be used to create sequential operations executed asynchronously from the UI thread. You can get it to do parallel operations, but generally the operations "join" back to the UI thread with some sort of result. (there's also the possibility of doing "fire-and-forget" types of asynchronous operations with await but it's not recommended). i.e. there's nothing inherent to async/await to support progress reporting.

    You can get progress out of code using async/await; but you need to use new progress interfaces like IProgress. For more info on progress reporting with async/await, see http://blogs.msdn.com/b/dotnet/archive/2012/06/06/async-in-4-5-enabling-progress-and-cancellation-in-async-apis.aspx. Migrating to this should just be a matter of calling an IProgress delegate instead of a Progress event.

提交回复
热议问题