Seems like a Maui thing according to Adolfo
The following works:
MauiControls.Application.Current?.Dispatcher.Dispatch(() => Navigation.PopAsync());
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm building a mobile and desktop app with Maui + MauiReactor that communicates with my server over Websockets. I have this working fine.
My problem is that if I try to Navigate to another page when I receive a Websocket reply:
await Navigation.pushAsync<NewPage>();
I get the following error:
UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread.
I understand why this happening, just not how best to handle it.
I can display a button after the message has been received, which the user can click to navigate which is obviously performing the navigaton on the UI thread due to the button click, but this feels really clunky. Is it possible to raise the process onto the UI thread so that I can programmatically navigate automatically?
My use case is as follows:
User starts the app, navigates to the sign in page, and enters credentials
Credentials get sent to my server over a websocket
Websocket reply confirms credentials and supplies a session token
Now I need to navigate to another page based on the current state of their profile settings i.e. if incomplete, go to profile page, if complete go back home. I would like this to be automatic without forcing the user to click a button to navigate.
Can anyone advise on how best to go about this?
Many thanks.
(I've just started my dotnet journey, still learning c# but enjoying every second of it, been doing FP for the last 8 yrs or so, enjoying a bit of OO again.)
Seems like a Maui thing according to Adolfo
The following works:
MauiControls.Application.Current?.Dispatcher.Dispatch(() => Navigation.PopAsync());