Skip to content

Bug: Using a non-reentrant wait synchronization context causes app to hang on exit #2531

Description

@benstevens48

Description

For more context see #2422. Basically, the issue is if I subclass DispatcherQueueSynchronizationContext to use a non-reentrant wait to avoid reentrancy issues in WindowsAppSDK, then the app hangs on exit. There is an easy workaround which is to revert to the standard wait on FrameworkShutdownStarting. However, it would be nice if this wasn't needed. I'm posting here now in case this reqires any .net runtime updates before v11 is released.

Steps To Reproduce

Use this code in app startup where CustomDispatcherQueueSynchronizationContext is given in #2422 (and remove the workaround when shutting down).

Application.Start((p) => {
    var context = new CustomDispatcherQueueSynchronizationContext(DispatcherQueue.GetForCurrentThread());
    SynchronizationContext.SetSynchronizationContext(context);
    _ = new App();
});

Expected Behavior

No hang on exit

Version Info

Last tested on CsWinRT 2.2, WindowsAppSDK 2.0

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions