Add NoMessagePumpSyncContext..ctor(SynchronizationContext) for Post/Send behaviors#1578
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an optional underlying SynchronizationContext to NoMessagePumpSyncContext so Post/Send can be delegated to a provided context (instead of always falling back to the base implementation), aligning behavior with scenarios that need main-thread scheduling while still preserving the non-pumping Wait override.
Changes:
- Added
NoMessagePumpSyncContext(SynchronizationContext)constructor that stores an underlying context. - Overrode
Post/Sendto delegate to the underlying context when provided. - Added tests covering default vs underlying-context
Post/Sendbehavior and null-argument validation for the new constructor.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Microsoft.VisualStudio.Threading/NoMessagePumpSyncContext.cs | Adds underlying-context constructor and delegates Post/Send to it when provided. |
| test/Microsoft.VisualStudio.Threading.Tests/NoMessagePumpSyncContextTests.cs | Adds unit tests for default vs delegated Post/Send behavior and constructor null-argument behavior. |
…/Send behaviors Previously, this class would always schedule work to the threadpool. This doesn't match requirements where the non-pumping code expects to schedule work on the main thread.
cf392f2 to
bb3388f
Compare
kayle
approved these changes
Apr 23, 2026
This was referenced Jun 22, 2026
Merged
Open
Merged
Merged
Merged
Merged
This was referenced Jun 28, 2026
Merged
Bump Microsoft.VisualStudio.Threading.Analyzers from 17.14.15 to 18.7.23
gaplin/DapperPlayground#246
Closed
Merged
Merged
chore: Bump Microsoft.VisualStudio.Threading.Analyzers from 17.14.15 to 18.7.23
cihanyakar/Markus#63
Open
Open
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, this class would always schedule work to the threadpool. This doesn't match requirements where the non-pumping code expects to schedule work on the main thread.