-
Notifications
You must be signed in to change notification settings - Fork 152
Description
Bug description
The default implementation on SynchronizationContext.CreateCopy() returns a new instance of its own type.
But that type has very different behavior than JoinableTaskSynchronizationContext, so it would be incorrect to return the base type from our derived type.
Repro steps
I don't know what failures this may lead to yet. But given when ExecutionContext is captured it can (sometimes?) flow SynchronizationContext, I suspect if we can isolate when that happens we can find a repro for a bug.
Expected behavior
We should override the CreateCopy() method and have it return a copy of the current instance. The copy should behave exactly like the original, including common values for all fields so that they share queues, etc. But it should be a unique instance (not this) to avoid exposing bugs in others' code such as that learned by WPF, as pointed out by @weltkante in #347.
Additional context
@jviau noticed some test failures while working on the ReentrantSemaphore in certain conditions that he attributed to our CreateCopy() behavior, IIRC.