Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

When to process data on startup, after splash screen

$
0
0

Hi,

I'm having trouble with a basic Xamarin.Forms iOS application. I have the following code:


public class App : Application
{
public App (IOfflineFileSync offlineFiles, ISaveAndLoad saveAndLoad)
{
MainPage = new LocalHtmlBaseUrl (offlineFiles, saveAndLoad);
}

    protected override void OnStart ()
    {
        // Handle when your app starts
    }

    protected override void OnSleep ()
    {
        // Handle when your app sleeps
    }

    protected override void OnResume ()
    {
        // Handle when your app resumes
    }
}

LocalHtmlBaseUrl has some code to process before rendering the WebView like so:


public LocalHtmlBaseUrl (IOfflineFileSync offlineFiles, ISaveAndLoad saveAndLoad)
{
var browser = new BaseUrlWebView (); // temporarily use this so we can custom-render in iOS

        GetOfflineFiles (offlineFiles, saveAndLoad, browser);


        Content = browser;
    }

The problem is, this seems to happen when the Splash Screen is displayed and when deploying to a device the app crashes because it's been displayed for too long. How can I fire GetOfflineFiles as a background task in the PCL? I tried to add "async" to the method but this doesn't work. The plan is I'll show a simple animation in place of the splash screen when this work is happening.

Thanks,
Colin


Viewing all articles
Browse latest Browse all 58056

Trending Articles