You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This method is like the WPF `Dispatcher.DisableProcessing()` method, except that it impacts the `SynchronizationContext` that `JoinableTask` delegates execute within.
As part of this, I introduce a test helper class for actually testing the penetrability of sync blocks so we can adequately test this new API. Since this test helper also can apply to `NoMessagePumpSyncContext` testing (which did not exist), I added new tests for that class too.
#pragma warning disable SA1629// Documentation text should end with a period
298
+
/// <summary>
299
+
/// Prevents filtered message pumps from running during synchronous waits for the ambient <see cref="JoinableTask"/>.
300
+
/// </summary>
301
+
/// <returns>
302
+
/// A value that may be disposed of when the need to suppress synchronous wait message pumps is ended.
303
+
/// Alternatively it may be discarded if the rest of the <see cref="JoinableTask"/> is intended to have processing disabled.
304
+
/// </returns>
305
+
/// <exception cref="InvalidOperationException">Thrown when called outside the context of a <see cref="JoinableTask"/>.</exception>
306
+
/// <remarks>
307
+
/// <para>
308
+
/// During a yielding <see langword="await"/> within a <see cref="JoinableTask"/>, no message pump ever runs
309
+
/// regardless of whether this method is called, except for the internal one that lets in only relevant work.
310
+
/// When user code runs within the <see cref="JoinableTask"/> delegate or its callees that ends up requiring
311
+
/// a synchronous block of the main thread (e.g. synchronous I/O or lock contention), this wait is typically
312
+
/// implemented by calling <see cref="SynchronizationContext.Wait(IntPtr[], bool, int)"/> on <see cref="SynchronizationContext.Current"/>.
313
+
/// The default implementation of this method allows for certain interruptions (e.g. COM RPC calls), which
314
+
/// <em>may</em> avoid deadlocks in certain situations.
315
+
/// </para>
316
+
/// <para>
317
+
/// Calling this method will replace the default implementation of <see cref="SynchronizationContext.Wait(IntPtr[], bool, int)"/>
318
+
/// with one that will not allow such interruptions while that <see cref="JoinableTask"/> is active and in control of
319
+
/// <see cref="SynchronizationContext.Current"/>.
320
+
/// </para>
321
+
/// <para>
322
+
/// Disabling processing has no effect on non-Windows operating systems.
323
+
/// </para>
324
+
/// <para>
325
+
/// Nested calls to <see cref="DisableProcessing"/> are ignored. Only the outermost call has an effect on the behavior of the ambient <see cref="JoinableTask"/>
326
+
/// and only disposing the return value from the outermost call will restore the default behavior.
327
+
/// </para>
328
+
/// <para>
329
+
/// Disposing the resulting value will revert to the default behavior.
330
+
/// Callers need not ever dispose of this value if the intent is to disable processing for the remainder of that
331
+
/// <see cref="JoinableTask"/>'s execution.
332
+
/// </para>
333
+
/// </remarks>
334
+
/// <example>
335
+
/// <para>
336
+
/// Here is a simple, common usage of this method:
0 commit comments