Is there a smarter way than a busy-wait to check for download completion of System.Net.WebClient.DownloadFileAsync()?

前端 未结 3 1558
长情又很酷
长情又很酷 2021-01-05 08:47

I\'m downloading a file using System.Net.WebClient.DownloadFileAsync(). The only reason for using the async version is to show the progress of the download. My code executio

3条回答
  •  日久生厌
    2021-01-05 09:05

    Use an AutoResetEvent. Call its Set() method in a DownloadFileCompleted event handler, its WaitOne() method after the DownloadFileAsync() call.

提交回复
热议问题