Last active
August 29, 2015 14:07
-
-
Save jchapuis/0e451d5b464f43a3826b to your computer and use it in GitHub Desktop.
Observable parallel query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ParallelQueryExtensions | |
{ | |
public static IObservable<T> ToUnorderedObservable<T>(this ParallelQuery<T> query) | |
{ | |
return Observable.Create<T>( | |
obs => | |
{ | |
try | |
{ | |
query.WithMergeOptions(ParallelMergeOptions.NotBuffered).ForAll(obs.OnNext); | |
obs.OnCompleted(); | |
} | |
catch (AggregateException e) | |
{ | |
obs.OnError(e.Flatten().InnerException); | |
} | |
return Disposable.Empty; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment