【发布时间】:2014-07-18 14:07:38
【问题描述】:
我想在 Windows Phone 8.1 Silverlight 中使用“Windows.Web.Http.HttpClient”实现进度条。
编辑:第一次尝试:
private async Task CheckProgress()
{
var df = httpClient.GetAsync(new Uri(uriString, UriKind.Absolute)).Progress = Progress;
// here i want to stop the execution till whole content downloaded
// Reason to wait here
// this client download will be used by one more async method. so i need to wait here till the file completely downloaded.
// this whole is done in this method only ( requirement)
}
private void Progress(IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> asyncInfo, HttpProgress progressInfo)
{
// here i getting the progress value.
// i have already set a call back method that report the progress on the UI.
}
再一次尝试:但是得到了异常Invocation of delegate at wrong time.
private async Task CheckProgress()
{
var df = httpClient.GetAsync(new Uri(uriString, UriKind.Absolute))
df.Progress = Progress;
await df;
// here i want to stop the execution till whole content downloaded
}
问题:
我只想停止CheckProgress() 方法,一直等到整个下载完成。
【问题讨论】:
-
也许你可以看看ManualResetEvent (msdn.microsoft.com/en-us/library/…)
-
您何时以及如何调用 CheckProgress()?
-
哈哈,我也是……我很困惑。你有完整的代码吗?
标签: c# asynchronous httpclient windows-phone-8.1