Skip to content

Add NoMessagePumpSyncContext..ctor(SynchronizationContext) for Post/Send behaviors#1578

Merged
AArnott merged 1 commit into
mainfrom
dev/andarno/scheduleNoPumpSC
Apr 23, 2026
Merged

Add NoMessagePumpSyncContext..ctor(SynchronizationContext) for Post/Send behaviors#1578
AArnott merged 1 commit into
mainfrom
dev/andarno/scheduleNoPumpSC

Conversation

@AArnott

@AArnott AArnott commented Apr 23, 2026

Copy link
Copy Markdown
Member

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.

@AArnott AArnott added this to the v18.7 milestone Apr 23, 2026
Copilot AI review requested due to automatic review settings April 23, 2026 16:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/Send to delegate to the underlying context when provided.
  • Added tests covering default vs underlying-context Post/Send behavior 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.

Comment thread src/Microsoft.VisualStudio.Threading/NoMessagePumpSyncContext.cs Outdated
Comment thread src/Microsoft.VisualStudio.Threading/NoMessagePumpSyncContext.cs
Comment thread src/Microsoft.VisualStudio.Threading/NoMessagePumpSyncContext.cs
Comment thread test/Microsoft.VisualStudio.Threading.Tests/NoMessagePumpSyncContextTests.cs Outdated
…/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.
@AArnott AArnott force-pushed the dev/andarno/scheduleNoPumpSC branch from cf392f2 to bb3388f Compare April 23, 2026 18:28
@AArnott AArnott enabled auto-merge April 23, 2026 18:29
Comment thread src/Microsoft.VisualStudio.Threading/NoMessagePumpSyncContext.cs
@AArnott AArnott merged commit 6d16fb4 into main Apr 23, 2026
9 checks passed
@AArnott AArnott deleted the dev/andarno/scheduleNoPumpSC branch April 23, 2026 21:40
This was referenced Jun 22, 2026
This was referenced Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants