16 types derived from SynchronizationContext
Microsoft.AspNetCore.Components (1)
Rendering\RendererSynchronizationContext.cs (1)
10internal sealed class RendererSynchronizationContext : SynchronizationContext
Microsoft.AspNetCore.Components.WebView.Photino (1)
PhotinoSynchronizationContext.cs (1)
22internal class PhotinoSynchronizationContext : SynchronizationContext
Microsoft.AspNetCore.Shared.Tests (1)
SingleThreadedSynchronizationContext.cs (1)
12internal class SingleThreadedSynchronizationContext : SynchronizationContext
Microsoft.AspNetCore.SignalR.Client.FunctionalTests (1)
HubConnectionTests.cs (1)
2923private class OneAtATimeSynchronizationContext : SynchronizationContext, IAsyncDisposable
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (1)
TestExportJoinableTaskContext+DenyExecutionSynchronizationContext.cs (1)
34internal sealed class DenyExecutionSynchronizationContext : SynchronizationContext
Microsoft.Extensions.AI.Tests (1)
ChatCompletion\FunctionInvokingChatClientTests.cs (1)
1065private sealed class CustomSynchronizationContext : SynchronizationContext
Microsoft.Extensions.Diagnostics.HealthChecks.Tests (1)
src\Shared\test\Shared.Tests\SingleThreadedSynchronizationContext.cs (1)
12internal class SingleThreadedSynchronizationContext : SynchronizationContext
Microsoft.Extensions.Http.Polly.Tests (1)
src\Shared\test\Shared.Tests\SingleThreadedSynchronizationContext.cs (1)
12internal class SingleThreadedSynchronizationContext : SynchronizationContext
Microsoft.Maui.Graphics.Win2D.WinUI.Desktop (1)
src\Graphics\src\Graphics\Platforms\Windows\AsyncPump.cs (1)
88 private sealed class SingleThreadSynchronizationContext : SynchronizationContext
ScenarioTests.Common.Tests (2)
ScenarioTestTypes.cs (1)
176public class SingleThreadSynchronizationContext : SynchronizationContext
ThreadHoppingSynchronizationContext.cs (1)
9public class ThreadHoppingSynchronizationContext : SynchronizationContext
System.ServiceModel.Primitives (2)
Internals\System\Runtime\IOThreadScheduler.cs (1)
555private class IOThreadSchedulerSynchronizationContext : SynchronizationContext
Internals\System\Runtime\ServiceModelSynchronizationContext.cs (1)
10internal class ServiceModelSynchronizationContext : SynchronizationContext
System.Windows.Forms (1)
System\Windows\Forms\WindowsFormsSynchronizationContext.cs (1)
11public sealed class WindowsFormsSynchronizationContext : SynchronizationContext, IDisposable
System.Windows.Forms.UI.IntegrationTests (1)
Infra\DenyExecutionSynchronizationContext.cs (1)
9internal class DenyExecutionSynchronizationContext : SynchronizationContext
UnitTests.Common (1)
TestTypes.cs (1)
266public class SingleThreadSynchronizationContext : SynchronizationContext
8 instantiations of SynchronizationContext
Client.ChannelLayer.IntegrationTests (1)
DuplexChannelWithSynchronizationContext.cs (1)
181context.SynchronizationContext = new SynchronizationContext();
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (1)
TestExportJoinableTaskContext+DenyExecutionSynchronizationContext.cs (1)
58UnderlyingContext = underlyingContext ?? new SynchronizationContext();
System.ComponentModel.EventBasedAsync (1)
System\ComponentModel\AsyncOperationManager.cs (1)
24SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
System.Private.CoreLib (2)
src\libraries\System.Private.CoreLib\src\System\Progress.cs (1)
102internal static readonly SynchronizationContext DefaultContext = new SynchronizationContext();
src\libraries\System.Private.CoreLib\src\System\Threading\SynchronizationContext.cs (1)
57public virtual SynchronizationContext CreateCopy() => new SynchronizationContext();
System.Windows.Forms (1)
System\Windows\Forms\WindowsFormsSynchronizationContext.cs (1)
165? new SynchronizationContext()
System.Windows.Forms.UI.IntegrationTests (2)
Infra\DenyExecutionSynchronizationContext.cs (2)
58(_underlyingContext ?? new SynchronizationContext()).Post(d, state); 77(_underlyingContext ?? new SynchronizationContext()).Send(d, state);
316 references to SynchronizationContext
Binding.Http.IntegrationTests (4)
OperationContextTests.cs (4)
34var exisitingSyncContext = SynchronizationContext.Current; 37SynchronizationContext.SetSynchronizationContext(ThreadHoppingSynchronizationContext.Instance); 58SynchronizationContext.SetSynchronizationContext(exisitingSyncContext);
Binding.Tcp.IntegrationTests (12)
OperationContextAsyncFlowTests.cs (12)
23var exisitingSyncContext = SynchronizationContext.Current; 26SynchronizationContext.SetSynchronizationContext(ThreadHoppingSynchronizationContext.Instance); 45SynchronizationContext.SetSynchronizationContext(exisitingSyncContext); 58var exisitingSyncContext = SynchronizationContext.Current; 61SynchronizationContext.SetSynchronizationContext(ThreadHoppingSynchronizationContext.Instance); 92SynchronizationContext.SetSynchronizationContext(exisitingSyncContext); 153var exisitingSyncContext = SynchronizationContext.Current; 156SynchronizationContext.SetSynchronizationContext(ThreadHoppingSynchronizationContext.Instance); 174SynchronizationContext.SetSynchronizationContext(exisitingSyncContext);
Client.ChannelLayer.IntegrationTests (11)
DuplexChannelWithSynchronizationContext.cs (11)
59SynchronizationContext callbackSyncContext = callbackService.SynchronizationContext; 101var prevCtx = SynchronizationContext.Current; 102SynchronizationContext.SetSynchronizationContext(syncCtx); 115SynchronizationContext.SetSynchronizationContext(prevCtx); 124SynchronizationContext callbackSyncContext = callbackService.SynchronizationContext; 167Assert.IsType<TestTypes.SingleThreadSynchronizationContext>(SynchronizationContext.Current); 196SynchronizationContext callbackSyncContext = callbackService.SynchronizationContext; 232Assert.IsType<TestTypes.SingleThreadSynchronizationContext>(SynchronizationContext.Current); 271SynchronizationContext = SynchronizationContext.Current; 286public SynchronizationContext SynchronizationContext { get; private set; }
dotnet-svcutil-lib (14)
FrameworkFork\System.ServiceModel\Internals\System\Runtime\TaskHelpers.cs (3)
282(SynchronizationContext.Current == null || 283(SynchronizationContext.Current.GetType() == typeof(SynchronizationContext)));
FrameworkFork\System.ServiceModel\System\ServiceModel\Dispatcher\DispatchRuntime.cs (2)
32private SynchronizationContext _synchronizationContext; 180public SynchronizationContext SynchronizationContext
FrameworkFork\System.ServiceModel\System\ServiceModel\Dispatcher\ThreadBehavior.cs (7)
17private readonly SynchronizationContext _context; 71SynchronizationContext syncContext = GetSyncContext(rpc.InstanceContext); 93private SynchronizationContext GetSyncContext(InstanceContext instanceContext) 96SynchronizationContext syncContext = instanceContext.SynchronizationContext ?? _context; 110SynchronizationContext syncContext = GetSyncContext(resume.GetMessageInstanceContext()); 137internal static SynchronizationContext GetCurrentSynchronizationContext() 139return SynchronizationContext.Current;
FrameworkFork\System.ServiceModel\System\ServiceModel\InstanceContext.cs (2)
24private SynchronizationContext _synchronizationContext; 128public SynchronizationContext SynchronizationContext
Microsoft.AspNetCore.Components (5)
Rendering\RendererSynchronizationContext.cs (4)
26public override SynchronizationContext CreateCopy() => 62var original = Current; 101var original = Current; 239var original = Current;
Rendering\RendererSynchronizationContextDispatcher.cs (1)
19public override bool CheckAccess() => SynchronizationContext.Current == _context;
Microsoft.AspNetCore.Components.Server.Tests (7)
Circuits\CircuitHostTest.cs (7)
109var original = SynchronizationContext.Current; 110SynchronizationContext.SetSynchronizationContext(null); 115Assert.Null(SynchronizationContext.Current); 118Assert.Null(SynchronizationContext.Current); 123SynchronizationContext.SetSynchronizationContext(original); 943Assert.Same(Dispatcher, SynchronizationContext.Current);
Microsoft.AspNetCore.Components.Tests (10)
Rendering\RendererSynchronizationContextTest.cs (10)
114SynchronizationContext capturedContext = null; 132SynchronizationContext original = SynchronizationContext.Current; 136SynchronizationContext.SetSynchronizationContext(context); 140capturedContext = SynchronizationContext.Current; 146SynchronizationContext.SetSynchronizationContext(original); 274SynchronizationContext capturedContext = null; 282capturedContext = SynchronizationContext.Current; 382SynchronizationContext capturedContext = null; 390capturedContext = SynchronizationContext.Current;
Microsoft.AspNetCore.Components.WebAssembly (3)
Hosting\WebAssemblyHostBuilder.cs (2)
224if (WebAssemblyDispatcher._mainSynchronizationContext == null && SynchronizationContext.Current != null) 226WebAssemblyDispatcher._mainSynchronizationContext = SynchronizationContext.Current;
Rendering\WebAssemblyDispatcher.cs (1)
12internal static SynchronizationContext? _mainSynchronizationContext;
Microsoft.AspNetCore.Components.WebView.Photino (3)
PhotinoDispatcher.cs (1)
21public override bool CheckAccess() => SynchronizationContext.Current == _context;
PhotinoSynchronizationContext.cs (2)
188public override SynchronizationContext CreateCopy() 252var original = Current;
Microsoft.AspNetCore.Shared.Tests (1)
SingleThreadedSynchronizationContext.cs (1)
28var previous = Current;
Microsoft.AspNetCore.SignalR.Client.FunctionalTests (4)
HubConnectionTests.cs (4)
2331var originalSynchronizationContext = SynchronizationContext.Current; 2332SynchronizationContext.SetSynchronizationContext(oneAtATimeSynchronizationContext); 2356SynchronizationContext.SetSynchronizationContext(originalSynchronizationContext);
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (10)
Threading\StaTaskScheduler.cs (4)
69var oldContext = SynchronizationContext.Current; 78SynchronizationContext.SetSynchronizationContext(synchronizationContext); 86SynchronizationContext.SetSynchronizationContext(oldContext);
Threading\SynchronizationContextTaskScheduler.cs (3)
18private readonly SynchronizationContext _synchronizationContext; 20internal SynchronizationContextTaskScheduler(SynchronizationContext synchronizationContext) 36if (SynchronizationContext.Current == _synchronizationContext)
Threading\WpfDispatcherTaskJoiner.cs (1)
19public bool IsDispatcherSynchronizationContext(SynchronizationContext context)
Threading\WpfTestRunner.cs (2)
67Debug.Assert(SynchronizationContext.Current is DispatcherSynchronizationContext); 79SynchronizationContext.SetSynchronizationContext(null);
Microsoft.CodeAnalysis.Workspaces (1)
Workspace\Host\TaskScheduler\TaskSchedulerProvider.cs (1)
24=> (SynchronizationContext.Current != null) ? TaskScheduler.FromCurrentSynchronizationContext() : TaskScheduler.Default;
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (19)
MEF\IDispatcherTaskJoiner.cs (1)
12bool IsDispatcherSynchronizationContext(SynchronizationContext current);
TestExportJoinableTaskContext.cs (14)
32var synchronizationContext = SynchronizationContext.Current; 35SynchronizationContext.SetSynchronizationContext(GetEffectiveSynchronizationContext()); 41SynchronizationContext.SetSynchronizationContext(synchronizationContext); 45private static (JoinableTaskContext joinableTaskContext, SynchronizationContext synchronizationContext) CreateJoinableTaskContext(IDispatcherTaskJoiner? dispatcherTaskJoiner) 48SynchronizationContext synchronizationContext; 50var currentContext = SynchronizationContext.Current; 81internal SynchronizationContext SynchronizationContext 86internal static SynchronizationContext? GetEffectiveSynchronizationContext() 88if (SynchronizationContext.Current is AsyncTestSyncContext asyncTestSyncContext) 90SynchronizationContext? innerSynchronizationContext = null; 94innerSynchronizationContext = SynchronizationContext.Current; 102return SynchronizationContext.Current;
TestExportJoinableTaskContext+DenyExecutionSynchronizationContext.cs (4)
51public DenyExecutionSynchronizationContext(SynchronizationContext? underlyingContext) 56private DenyExecutionSynchronizationContext(SynchronizationContext? underlyingContext, Thread? mainThread, StrongBox<ExceptionDispatchInfo>? failedTransfer) 65private SynchronizationContext UnderlyingContext 139public override SynchronizationContext CreateCopy()
Microsoft.Extensions.AI.Tests (3)
ChatCompletion\FunctionInvokingChatClientTests.cs (3)
1024SynchronizationContext ctx = new CustomSynchronizationContext(); 1025SynchronizationContext.SetSynchronizationContext(ctx); 1047Assert.Same(ctx, SynchronizationContext.Current);
Microsoft.Extensions.Diagnostics.HealthChecks.Tests (1)
src\Shared\test\Shared.Tests\SingleThreadedSynchronizationContext.cs (1)
28var previous = Current;
Microsoft.Extensions.Http.Polly.Tests (1)
src\Shared\test\Shared.Tests\SingleThreadedSynchronizationContext.cs (1)
28var previous = Current;
Microsoft.Extensions.TimeProvider.Testing.Tests (1)
FakeTimeProviderTests.cs (1)
530SynchronizationContext.SetSynchronizationContext(null);
Microsoft.Maui (3)
Dispatching\DispatcherExtensions.cs (3)
96 /// <returns>A <see cref="SynchronizationContext"/> object representing the current synchronization context.</returns> 97 public static Task<SynchronizationContext> GetSynchronizationContextAsync(this IDispatcher dispatcher) => 98 dispatcher.DispatchAsync(() => SynchronizationContext.Current!);
Microsoft.Maui.Controls (1)
Device.cs (1)
115 public static Task<SynchronizationContext> GetMainThreadSynchronizationContextAsync() =>
Microsoft.Maui.Essentials (3)
MainThread\MainThread.shared.cs (3)
163 public static async Task<SynchronizationContext> GetMainThreadSynchronizationContextAsync() 165 SynchronizationContext ret = null; 167 ret = SynchronizationContext.Current).ConfigureAwait(false);
Microsoft.Maui.Graphics.Win2D.WinUI.Desktop (8)
src\Graphics\src\Graphics\Platforms\Windows\AsyncPump.cs (8)
32 var prevCtx = SynchronizationContext.Current; 37 SynchronizationContext.SetSynchronizationContext(syncCtx); 52 SynchronizationContext.SetSynchronizationContext(prevCtx); 63 var prevCtx = SynchronizationContext.Current; 68 SynchronizationContext.SetSynchronizationContext(syncCtx); 83 SynchronizationContext.SetSynchronizationContext(prevCtx);
mscorlib (1)
src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
1153[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.SynchronizationContext))]
netstandard (1)
netstandard.cs (1)
2105[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.SynchronizationContext))]
ScenarioTests.Common.Tests (8)
ScenarioTestTypes.cs (8)
251var prevCtx = SynchronizationContext.Current; 255SynchronizationContext.SetSynchronizationContext(syncCtx); 265SynchronizationContext.SetSynchronizationContext(prevCtx); 271var prevCtx = SynchronizationContext.Current; 275SynchronizationContext.SetSynchronizationContext(syncCtx); 285SynchronizationContext.SetSynchronizationContext(prevCtx);
System.ComponentModel.EventBasedAsync (9)
System\ComponentModel\AsyncOperation.cs (4)
10private readonly SynchronizationContext _syncContext; 17private AsyncOperation(object? userSuppliedState, SynchronizationContext syncContext) 38public SynchronizationContext SynchronizationContext 102internal static AsyncOperation CreateOperation(object? userSuppliedState, SynchronizationContext syncContext)
System\ComponentModel\AsyncOperationManager.cs (5)
18public static SynchronizationContext SynchronizationContext 22if (SynchronizationContext.Current == null) 24SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); 27return SynchronizationContext.Current!; 33SynchronizationContext.SetSynchronizationContext(value);
System.IO.Pipelines (10)
System\IO\Pipelines\CompletionData.cs (2)
13public SynchronizationContext? SynchronizationContext { get; } 15public CompletionData(Action<object?> completion, object? completionState, ExecutionContext? executionContext, SynchronizationContext? synchronizationContext)
System\IO\Pipelines\PipeAwaitable.cs (5)
92SynchronizationContext? synchronizationContext = schedulingContext?.SynchronizationContext; 131SynchronizationContext? sc = SynchronizationContext.Current; 132if (sc != null && sc.GetType() != typeof(SynchronizationContext)) 206public SynchronizationContext? SynchronizationContext { get; set; }
System\IO\Pipelines\PipeOptions.cs (3)
25/// <param name="useSynchronizationContext"><see langword="true" /> if asynchronous continuations should be executed on the <see cref="System.Threading.SynchronizationContext" /> they were captured on; <see langword="false" /> otherwise. This takes precedence over the schedulers specified in <see cref="System.IO.Pipelines.PipeOptions.ReaderScheduler" /> and <see cref="System.IO.Pipelines.PipeOptions.WriterScheduler" />.</param> 88/// <summary>Gets a value that determines if asynchronous callbacks and continuations should be executed on the <see cref="System.Threading.SynchronizationContext" /> they were captured on. This takes precedence over the schedulers specified in <see cref="System.IO.Pipelines.PipeOptions.ReaderScheduler" /> and <see cref="System.IO.Pipelines.PipeOptions.WriterScheduler" />.</summary> 89/// <value><see langword="true" /> if asynchronous callbacks and continuations should be executed on the <see cref="System.Threading.SynchronizationContext" /> they were captured on; otherwise, <see langword="false" />.</value>
System.Private.CoreLib (92)
src\libraries\System.Private.CoreLib\src\System\Progress.cs (6)
16/// <see cref="SynchronizationContext"/> instance captured 23private readonly SynchronizationContext _synchronizationContext; 34_synchronizationContext = SynchronizationContext.Current ?? ProgressStatics.DefaultContext; 43/// Depending on the <see cref="SynchronizationContext"/> instance captured by 58/// <see cref="SynchronizationContext"/> captured when the instance was constructed. 102internal static readonly SynchronizationContext DefaultContext = new SynchronizationContext();
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\AsyncMethodBuilderCore.cs (1)
34SynchronizationContext? previousSyncCtx = currentThread._synchronizationContext;
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\AsyncVoidMethodBuilder.cs (6)
17private SynchronizationContext? _synchronizationContext; 25SynchronizationContext? sc = SynchronizationContext.Current; 94SynchronizationContext? context = _synchronizationContext; 123SynchronizationContext? context = _synchronizationContext; 150private static void NotifySynchronizationContextOfCompletion(SynchronizationContext context)
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\YieldAwaitable.cs (6)
85SynchronizationContext? syncCtx = SynchronizationContext.Current; 86if (syncCtx != null && syncCtx.GetType() != typeof(SynchronizationContext)) 129SynchronizationContext? syncCtx = SynchronizationContext.Current; 130if (syncCtx != null && syncCtx.GetType() != typeof(SynchronizationContext))
src\libraries\System.Private.CoreLib\src\System\Threading\CancellationToken.cs (5)
152/// the current <see cref="SynchronizationContext">SynchronizationContext</see> and use it 194/// will be captured along with the delegate and will be used when executing it. The current <see cref="SynchronizationContext"/> is not captured. 221/// the current <see cref="SynchronizationContext">SynchronizationContext</see> and use it 279/// the current <see cref="SynchronizationContext">SynchronizationContext</see> and use it 293source.Register(callback, state, useSynchronizationContext ? SynchronizationContext.Current : null, useExecutionContext ? ExecutionContext.Capture() : null) :
src\libraries\System.Private.CoreLib\src\System\Threading\CancellationTokenSource.cs (2)
587Delegate callback, object? stateForCallback, SynchronizationContext? syncContext, ExecutionContext? executionContext) 1203public SynchronizationContext? SynchronizationContext;
src\libraries\System.Private.CoreLib\src\System\Threading\ExecutionContext.cs (1)
163SynchronizationContext? previousSyncCtx = currentThread._synchronizationContext;
src\libraries\System.Private.CoreLib\src\System\Threading\SynchronizationContext.cs (3)
16public static SynchronizationContext? Current => Thread.CurrentThread._synchronizationContext; 55public static void SetSynchronizationContext(SynchronizationContext? syncContext) => Thread.CurrentThread._synchronizationContext = syncContext; 57public virtual SynchronizationContext CreateCopy() => new SynchronizationContext();
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\ConfigureAwaitOptions.cs (1)
18/// Attempt to marshal the continuation back to the original <see cref="SynchronizationContext"/> or
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Sources\ManualResetValueTaskSourceCore.cs (12)
135if (SynchronizationContext.Current is SynchronizationContext sc && 136sc.GetType() != typeof(SynchronizationContext)) 244Debug.Assert(context is TaskScheduler or SynchronizationContext, $"context is {context}"); 259Debug.Assert(scheduler is SynchronizationContext or TaskScheduler, $"{nameof(scheduler)} is {scheduler}"); 280context is SynchronizationContext or TaskScheduler or CapturedSchedulerAndExecutionContext, 285case SynchronizationContext sc: 295if (cc._scheduler is SynchronizationContext ccsc) 307static void ScheduleSynchronizationContext(SynchronizationContext sc, Action<object?> continuation, object? state) => 344SynchronizationContext? syncContext = SynchronizationContext.Current; 360SynchronizationContext.SetSynchronizationContext(syncContext);
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Task.cs (7)
1899internal static void ThrowAsync(Exception exception, SynchronizationContext? targetContext) 2503if (SynchronizationContext.Current is SynchronizationContext syncCtx && syncCtx.GetType() != typeof(SynchronizationContext)) 2576if (SynchronizationContext.Current is SynchronizationContext syncCtx && syncCtx.GetType() != typeof(SynchronizationContext))
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\TaskContinuation.cs (6)
375private readonly SynchronizationContext m_syncContext; 382SynchronizationContext context, Action action, bool flowExecutionContext) : 396m_syncContext == SynchronizationContext.Current) 610SynchronizationContext? ctx = SynchronizationContext.Current; 611if (ctx != null && ctx.GetType() != typeof(SynchronizationContext)) return false;
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\TaskScheduler.cs (15)
322/// associated with the current <see cref="SynchronizationContext"/>. 327/// <see cref="SynchronizationContext.Post">Post</see> method 332/// the current <see cref="SynchronizationContext">SynchronizationContext</see>, as 333/// determined by <see cref="SynchronizationContext.Current">SynchronizationContext.Current</see>. 533/// <see cref="SynchronizationContext.Post"/> on the <see cref="SynchronizationContext"/> 534/// that its associated with. The default constructor for this class binds to the current <see cref="SynchronizationContext"/> 538private readonly SynchronizationContext m_synchronizationContext; 541/// Constructs a SynchronizationContextTaskScheduler associated with <see cref="SynchronizationContext.Current"/> 543/// <exception cref="InvalidOperationException">This constructor expects <see cref="SynchronizationContext.Current"/> to be set.</exception> 546m_synchronizationContext = SynchronizationContext.Current ?? 554/// Simply posts the tasks to be executed on the associated <see cref="SynchronizationContext"/>. 566/// the associated <see cref="SynchronizationContext"/>. 572if (SynchronizationContext.Current == m_synchronizationContext) 591/// By default it returns 1, because a <see cref="SynchronizationContext"/> based
src\libraries\System.Private.CoreLib\src\System\Threading\WaitHandle.cs (6)
136SynchronizationContext? context = SynchronizationContext.Current; 309SynchronizationContext? context = SynchronizationContext.Current; 371SynchronizationContext? context = SynchronizationContext.Current;
src\System\Runtime\CompilerServices\AsyncHelpers.CoreCLR.cs (13)
22public SynchronizationContext? _previousSyncCtx; 212static abstract void PostToSyncContext(T task, SynchronizationContext syncCtx); 280public static void PostToSyncContext(ThunkTask<T> task, SynchronizationContext syncContext) 335public static void PostToSyncContext(ThunkTask task, SynchronizationContext syncContext) 473SynchronizationContext? ctx = Thread.CurrentThreadAssumedInitialized._synchronizationContext; 474if (ctx == null || ctx.GetType() == typeof(SynchronizationContext)) 492Debug.Assert(continuationContext is SynchronizationContext { }); 493SynchronizationContext continuationSyncCtx = (SynchronizationContext)continuationContext; 605private static void CaptureContexts(out ExecutionContext? execCtx, out SynchronizationContext? syncCtx) 613private static void RestoreContexts(bool suspended, ExecutionContext? previousExecCtx, SynchronizationContext? previousSyncCtx) 628private static void CaptureContinuationContext(SynchronizationContext syncCtx, ref object context, ref CorInfoContinuationFlags flags) 630if (syncCtx != null && syncCtx.GetType() != typeof(SynchronizationContext))
src\System\Threading\SynchronizationContext.CoreCLR.cs (1)
8private static int InvokeWaitMethodHelper(SynchronizationContext syncContext, IntPtr[] waitHandles, bool waitAll, int millisecondsTimeout)
src\System\Threading\Thread.CoreCLR.cs (1)
31internal SynchronizationContext? _synchronizationContext; // maintained separately from ExecutionContext
System.ServiceModel.Primitives (25)
Internals\System\Runtime\IOThreadScheduler.cs (5)
56private static readonly SynchronizationContext s_syncContext = new IOThreadSchedulerSynchronizationContext(); 94SynchronizationContext savedCtx = SynchronizationContext.Current; 95SynchronizationContext.SetSynchronizationContext(s_syncContext); 97SynchronizationContext.SetSynchronizationContext(savedCtx);
Internals\System\Runtime\TaskHelpers.cs (9)
374if (SynchronizationContext.Current == ServiceModelSynchronizationContext.Instance) 391SynchronizationContext.SetSynchronizationContext(null); 407private readonly SynchronizationContext _prevContext; 411_prevContext = SynchronizationContext.Current; 412SynchronizationContext.SetSynchronizationContext(ServiceModelSynchronizationContext.Instance); 417SynchronizationContext.SetSynchronizationContext(_prevContext); 443(SynchronizationContext.Current == null || 444(SynchronizationContext.Current.GetType() == typeof(SynchronizationContext)));
System\ServiceModel\Dispatcher\DispatchRuntime.cs (2)
26private SynchronizationContext _synchronizationContext; 172public SynchronizationContext SynchronizationContext
System\ServiceModel\Dispatcher\ThreadBehavior.cs (7)
16private readonly SynchronizationContext _context; 70SynchronizationContext syncContext = GetSyncContext(rpc.InstanceContext); 92private SynchronizationContext GetSyncContext(InstanceContext instanceContext) 95SynchronizationContext syncContext = instanceContext.SynchronizationContext ?? _context; 109SynchronizationContext syncContext = GetSyncContext(resume.GetMessageInstanceContext()); 136internal static SynchronizationContext GetCurrentSynchronizationContext() 138return SynchronizationContext.Current;
System\ServiceModel\InstanceContext.cs (2)
23private SynchronizationContext _synchronizationContext; 131public SynchronizationContext SynchronizationContext
System.Threading (1)
artifacts\obj\System.Threading\Debug\net10.0\System.Threading.Forwards.cs (1)
28[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.SynchronizationContext))]
System.Threading.Channels (8)
System\Threading\Channels\AsyncOperation.cs (8)
225SynchronizationContext? sc = 226ctx as SynchronizationContext ?? 227(ctx as CapturedSchedulerAndExecutionContext)?._scheduler as SynchronizationContext; 233if (RunContinuationsAsynchronously || sc != SynchronizationContext.Current) 318SynchronizationContext? sc = null; 322sc = SynchronizationContext.Current; 323if (sc is not null && sc.GetType() != typeof(SynchronizationContext)) 400Debug.Assert(scheduler is SynchronizationContext or TaskScheduler, $"{nameof(scheduler)} is {scheduler}");
System.Windows.Forms (21)
System\Windows\Forms\Control.cs (6)
6101if (SynchronizationContext.Current is null) 6106tme._syncContext = SynchronizationContext.Current; 6124SynchronizationContext? oldContext = SynchronizationContext.Current; 6128SynchronizationContext.SetSynchronizationContext(tme._syncContext); 6134SynchronizationContext.SetSynchronizationContext(oldContext);
System\Windows\Forms\Control.ThreadMethodEntry.cs (1)
29internal SynchronizationContext? _syncContext;
System\Windows\Forms\Dialogs\TaskDialog\TaskDialog.cs (3)
402if (SynchronizationContext.Current is null) 407var syncContext = SynchronizationContext.Current
System\Windows\Forms\Form.cs (6)
5613if (SynchronizationContext.Current is null) 5618var syncContext = SynchronizationContext.Current 5913if (SynchronizationContext.Current is null) 5918var syncContext = SynchronizationContext.Current
System\Windows\Forms\ToolTip\KeyboardToolTipStateMachine.cs (1)
180SynchronizationContext.Current?.Post(expirationCallback, tool);
System\Windows\Forms\WindowsFormsSynchronizationContext.cs (4)
24private static SynchronizationContext? t_previousSyncContext; 92public override SynchronizationContext CreateCopy() 140SynchronizationContext currentContext = AsyncOperationManager.SynchronizationContext; 143if (currentContext is null || currentContext.GetType() == typeof(SynchronizationContext))
System.Windows.Forms.UI.IntegrationTests (7)
Infra\ControlTestBase.cs (2)
68_denyExecutionSynchronizationContext = new DenyExecutionSynchronizationContext(SynchronizationContext.Current!); 94SynchronizationContext.SetSynchronizationContext(_denyExecutionSynchronizationContext.UnderlyingContext);
Infra\DenyExecutionSynchronizationContext.cs (5)
11private readonly SynchronizationContext _underlyingContext; 15public DenyExecutionSynchronizationContext(SynchronizationContext underlyingContext) 20private DenyExecutionSynchronizationContext(SynchronizationContext underlyingContext, Thread? mainThread, StrongBox<ExceptionDispatchInfo>? failedTransfer) 27internal SynchronizationContext UnderlyingContext => _underlyingContext; 81public override SynchronizationContext CreateCopy()
UnitTests.Common (8)
TestTypes.cs (8)
319var prevCtx = SynchronizationContext.Current; 323SynchronizationContext.SetSynchronizationContext(syncCtx); 333SynchronizationContext.SetSynchronizationContext(prevCtx); 339var prevCtx = SynchronizationContext.Current; 343SynchronizationContext.SetSynchronizationContext(syncCtx); 353SynchronizationContext.SetSynchronizationContext(prevCtx);