Reputation: 65
I have a reactiveui/rx app. Currently, I'm developing it's desktop part, so it's a wpf application. I would like to create each window in its separate thread, because of performance reasons.
That's why I need ObserveOn to be run on a current thread
someCollection.Changed.Buffer(TimeSpan.FromSeconds(n)).ObserveOn(*should be a link to a current thread*).Subscribe(bufferedItems => {})
also, this code is located in a portable lib, that's why I can't use System.Threading.Thread class
Is there any workaround?
Upvotes: 2
Views: 818
Reputation: 10783
If you can capture the Dispatcher
you can then provide that to the DispatcherScheduler
.
var currentDispatcher = Dispatcher.CurrentDispatcher;
var scheduler = new DispatcherScheduler(currentDispatcher);
Observable.Empty<int>().ObserveOn(scheduler)....
Upvotes: 3