Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INavigationAware async methods do not run on UI synchronization context #1306

Open
elliot-gawthrop opened this issue Jan 6, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@elliot-gawthrop
Copy link

Describe the bug

The framework invokes the INavigationAware callbacks through a Task.Run, which causes the callbacks to be run on the thread pool.

Any cross-thread exceptions that do occur within the callback are silently swallowed because the result of the task is discarded.

To Reproduce

Add the following code to an INavgiationAware callback:

if (Thread.CurrentThread != Application.Current.Dispatcher.Thread)
{
    Debugger.Break();
}

Expected behavior

As this interface is intended to be implemented by view models, I expect the callbacks to be run on the UI synchronization context, allowing UI-bound properties to be modified without having to deal without posting the updates to the UI synchronization context manually.

Screenshots

No response

OS version

Windows 10

.NET version

.NET 9

WPF-UI NuGet version

4.0.0-rc.3

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant