Skip to content

Latest commit

 

History

History
28 lines (22 loc) · 956 Bytes

Readme.md

File metadata and controls

28 lines (22 loc) · 956 Bytes

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.