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

Splash screen Backgrounding and UI navigation

$
0
0

Good Day i have the following scenario in Xamarin Forms.

My Splash screen loads data from a web service in the background. Currently i Kick that off with

Task.Run(async () => await GetData());

this happens in the viewmodel constructor as i need it to happen without user interaction

Ultimately this procedure finishes up and i then need to navigate to the next screen.
I have implemented a navigation service that i call like this.

var navigationService = new NavigationService();
navigationService.NavigateToMainMenu();

This throws an error and tells me i
"The application called an interface that was marshalled for a different thread" UWP
"Only the original thread that created a view hierarchy can touch its views" Android

and it works fine on all other screens but my splash screen . I believe it has to do with the way
it initiates the GetData method. On all other screens navigation happens with no problem as the processing is kicked off by the user firing a
command

example:

AuthMobileUser = new Command(async () => await Authenticate(), () => canAuth);

when i navigate from inside Authenticate() all is fine. All my splash screen needs to do is just run the background task and navigate when done.

Why does this seem so complicated. Can anyone please send me in the right direction.

Regards

WIL


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>