From b06cfe598fdff626d3e7a8581660a72c67d07954 Mon Sep 17 00:00:00 2001 From: Lifeng Lu Date: Tue, 16 Sep 2025 20:08:27 -0700 Subject: [PATCH] remove NotifyOfCrossThreadDependency call when a debugger is attached, NotifyOfCrossThreadDependency will freeze the thread to send notification to the debugger. Because this NoMessagePumpSynchronizationContext is heavily used, including nested inside code holding the JTF lock, this leads the process being debugged becomes extremely slow when JTF is heavily used. --- src/Microsoft.VisualStudio.Threading/JoinableTaskContext.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Microsoft.VisualStudio.Threading/JoinableTaskContext.cs b/src/Microsoft.VisualStudio.Threading/JoinableTaskContext.cs index fa3cb7339..3baa6cbae 100644 --- a/src/Microsoft.VisualStudio.Threading/JoinableTaskContext.cs +++ b/src/Microsoft.VisualStudio.Threading/JoinableTaskContext.cs @@ -302,11 +302,6 @@ protected internal virtual SynchronizationContext NoMessagePumpSynchronizationCo { get { - // Callers of this method are about to take a private lock, which tends - // to cause a deadlock while debugging because of lock contention with the - // debugger's expression evaluator. So prevent that. - Debugger.NotifyOfCrossThreadDependency(); - return NoMessagePumpSyncContext.Default; } }