How to track if an async/awaitable task is running

后端 未结 3 1657
执笔经年
执笔经年 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:37

    If you're using a Task you've created, you can check the Task's Status property (or just see Task.IsCompleted if completion is the only state you are interested in).

    That being said, await will not "return" until the operation either completes, raises an exception, or cancels. You can basically safely assume that, if you're still waiting on the "await", your task hasn't completed.

提交回复
热议问题