PureWeen / XamarinDispatchScheduler

MIT License
11 stars 3 forks source link

Xamarin Main Thread Dispatcher

Nuget

Examples

Observable
    .Timer(TimeSpan.FromSeconds(2))
    .ObserveOn(XamarinDispatcherScheduler.Current)
    .Subscribe(_ =>
    {
        lblChangeMe.Text = "Changed";
    });
//Helper to check if you're on the main thread
if (!XamarinDispatcherScheduler.OnMainThread())
{
    throw new Exception("Scheduler fail");
}

I borrowed from the CoreDispatchScheduler From Rx.NET and the Xamarin.Forms BeginInvokeOnMainThread implementations to create a combined Scheduler that will work Cross Platform for Xamarin.