开发者

C# DownloadFileAsync Callbacks Not Being Triggered

For some reason, the Async开发者_如何学运维 callbacks I've specified don't seem to get called. I've got the following in a Thread started by the original application thread:

WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += DownloadCompleted;
webClient.DownloadProgressChanged += DownloadProgressChanged;
webClient.DownloadFileAsync(new Uri(downloadUrl), tempPath);

And for the callbacks I've got:

public void DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
    Console.WriteLine("progress");
}

public void DownloadCompleted(object sender, AsyncCompletedEventArgs e)
{
    Console.WriteLine("completed");
}

I've used breakpoints to verify that the downloadUrl and tempPath strings are both valid (and I can see the downloaded file in Windows Explorer). Any insight on why the callbacks wouldn't be trigger? Thanks!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜