0
我試圖使用Reactive Extensions(Rx)來訂閱WebClient.DownloadProgressChanged
。至於我可以工作了,因爲DownloadProgressChanged
使用自定義的委託類型,我需要使用真囉嗦FromEvent
超載:與WebClient.DownloadProgressChanged一起使用Observable.FromEvent
var progress = Observable.FromEvent<DownloadProgressChangedEventHandler,
DownloadProgressChangedEventArgs>(
h => new DownloadProgressChangedEventHandler(h),
h => client.DownloadProgressChanged += h,
h => client.DownloadProgressChanged -= h);
然而,progress
類型爲IObservable<IEvent>
,而不是預期的IObservable<IEvent<DownloadProgressChangedEventArgs>>
。
我在做什麼錯?
進行了測試,雖然Reflector似乎顯示正確的返回類型。我會嘗試使用最新版本。 – 2011-01-30 08:11:24