2011-01-29 19 views
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>>

我在做什麼錯?

回答

0

我剛剛試用了

IObservable<IEvent<DownloadProgressChangedEventArgs>>. 

什麼版本的Rx您使用的是進步型的?我剛剛使用最新版本(v1.0.2838.0)

+0

進行了測試,雖然Reflector似乎顯示正確的返回類型。我會嘗試使用最新版本。 – 2011-01-30 08:11:24