detecting connection drops while WebClient is downloading a file asynchronously (in C#)

天涯浪子 提交于 2019-12-05 03:56:31

The best way to do what you're asking is probably to implement your own timeout for the call.

Basically, create a timer that gets reset every time the DownloadProgressChanged event gets fired. That way, if you don't get any progress updates within your timeout period, you can call the CancelAsync command on the WebClient so you're not waiting around forever.

That's the only way I've been able to do it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!