【发布时间】:2017-01-11 23:38:31
【问题描述】:
我创建此方法是为了从事件中创建Observable。我正在尝试下载文件并更新进度条:
private void BuildObservables(WebClient webClient)
{
Observable.FromEventPattern<AsyncCompletedEventHandler, AsyncCompletedEventArgs>(h => webClient.DownloadFileCompleted += h, h => webClient.DownloadFileCompleted -= h)
.Select(ep => ep.EventArgs)
.Subscribe(
_ =>
{
//stuff code
},
_ => this.WizardViewModel.PageCompleted() <<<<< (*) NOT REACHED
);
Observable.FromEventPattern<DownloadProgressChangedEventHandler, DownloadProgressChangedEventArgs>(h => webClient.DownloadProgressChanged += h, h => webClient.DownloadProgressChanged -= h)
.Select(ep => ep.EventArgs)
.Subscribe(
a =>
{
<<<<< (*) NOT REACHED
this.progressEdit.Position = a.ProgressPercentage;
progressEdit.Update();
}
);
}
我正面临着(*) 在源上标记的点(onCompleted 和 onNext)没有到达。
有什么想法吗?
【问题讨论】:
标签: .net system.reactive