I've created this method in order to create Observable
's from events. I'm trying to download a file, and update a progress bar:
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();
}
);
}
I'm facing up that (*)
point marked on source (onCompleted
and onNext
) are not reached.
Any ideas?