Wait for a void async method

后端 未结 6 1268
终归单人心
终归单人心 2020-12-02 07:20

How can I wait for a void async method to finish its job?

for example, I have a function like below:

async void LoadBlahBlah()
{
    awa         


        
6条回答
  •  时光取名叫无心
    2020-12-02 08:06

    do a AutoResetEvent, call the function then wait on AutoResetEvent and then set it inside async void when you know it is done.

    You can also wait on a Task that returns from your void async

提交回复
热议问题