Forum Xamarin.Forms

PushAsync from another thread does execute

using System;
using System.Collections.Generic;
using Xamarin.Forms;

namespace LeadYouToMe
{
public partial class SplashPage : ContentPage
{
System.Threading.Timer _SplashTimer = null;

    public SplashPage ()
    {
        InitializeComponent ();

        _SplashTimer = new System.Threading.Timer ( SplashTimerCallback, null, 5000, 10000);
    }

    protected void SplashTimerCallback( object state )
    {
        if (_SplashTimer != null)
        {
            _SplashTimer.Dispose ();
            _SplashTimer = null;
        }

        // navigate to the normal start page..
        this.Navigation.PushAsync (new StartPage());
    }
}

}

I'm just trying to do a short timed splash screen, I know how to do it in normal android apps, but not in Xamarin Forms. There is no "runonuithread" or "invokeonuithread" as on Ios or android.

The page gets created, I can set break points in the constructor, but never gets displayed. I can verify the page works by skipping my splash page, and just using StartPage as my initial page.

Any suggestions would be appreciated.

Posts

  • MarshallMarshall USMember ✭✭

    you can use "Device.BeginInvokeOnMainThread()"

    maybe that is what you're looking for.

  • ChrisTurnerChrisTurner USMember

    Absolutely perfect. Thank you. I searched for it but failed to find it. Much appreciated.

Sign In or Register to comment.