Webclient's DownloadStringCompleted event handler never called

后端 未结 2 1869
执笔经年
执笔经年 2021-01-22 03:29

I\'m trying to make an asynchronous HTTP GET request using Webclient, however, the registered callback never gets called. I\'ve also tried with the sync one, and it worked fine.

2条回答
  •  自闭症患者
    2021-01-22 04:22

    Maybe because you disposing the WebClient before it finished downloading. The code execution don't stop on asyncWebRequest.DownloadStringAsync(url); and you are disposing the WebClient object by closing the using statement.

    try to dispose the WebClient on asyncWebRequest_DownloadStringCompleted.

    results

    enter image description here

提交回复
热议问题