Hey!
I have a C# class file where I navigate to other pages, depending on the input. Since the interface is something different than a page, I have to invoke page navigation with InvokeOnMainThreadAsync. I did this with the following method:
public void Page_Navigation(Page navigationpage)
{
Device.InvokeOnMainThreadAsync(async () =>
{
if (navigationpage == null)
{
await Navigation.PopAsync();
}
else
{
var currentPage = Navigation.NavigationStack.LastOrDefault();
await Navigation.PushAsync(navigationpage);
Navigation.RemovePage(currentPage);
}
});
}
Calling the method looks like this:

I test everything on Android, but when I'm done I also test it on iOS just to be sure. On Android everything works, but on iOS I get the following error when I call with method:
"UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread."
That something like this occurs is one thing, but that it only happens on iOS is something else. Does anyone know what is wrong here and how to fix it?
Best