Skip to content

Offer a single-threaded SynchronizationContext implementation #323

@AArnott

Description

@AArnott

Is your feature request related to a problem? Please describe.

On .NET Core there is no single-threaded SynchronizationContext to use, thereby making JoinableTaskFactory.SwitchToMainThreadAsync() no-op. Even .NET Core 3.x won't help everyone since they may be running on non-Windows platforms.

Also when unit testing a library that runs in a GUI app, it requires some significant setup to emulate a main thread.

Describe the solution you'd like

We can offer a single-threaded SynchronizationContext as a public class in the library and document best practices for testing that uses it.

This new class would also be available for use in non-testing processes on non-Windows platforms for folks who want to use it.

Additional context

More discussion on this with @weltkante and @sharwell is available in #322

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions