@@ -24,6 +24,7 @@ namespace System.Threading
2424 public sealed class ExecutionContext : IDisposable , ISerializable
2525 {
2626 internal static readonly ExecutionContext Default = new ExecutionContext ( isDefault : true ) ;
27+ internal static readonly ExecutionContext DefaultFlowSuppressed = new ExecutionContext ( AsyncLocalValueMap . Empty , Array . Empty < IAsyncLocal > ( ) , isFlowSuppressed : true ) ;
2728
2829 private readonly IAsyncLocalValueMap m_localValues ;
2930 private readonly IAsyncLocal [ ] m_localChangeNotifications ;
@@ -63,15 +64,15 @@ private ExecutionContext ShallowClone(bool isFlowSuppressed)
6364 {
6465 Debug . Assert ( isFlowSuppressed != m_isFlowSuppressed ) ;
6566
66- if ( ! isFlowSuppressed &&
67- ( m_localValues == null ||
68- m_localValues . GetType ( ) == typeof ( AsyncLocalValueMap . EmptyAsyncLocalValueMap ) )
69- )
67+ if ( m_localValues == null ||
68+ m_localValues . GetType ( ) == typeof ( AsyncLocalValueMap . EmptyAsyncLocalValueMap ) )
7069 {
71- return null ; // implies the default context
70+ return isFlowSuppressed ?
71+ DefaultFlowSuppressed :
72+ null ; // implies the default context
7273 }
73- // Flow suppressing a Default context will have null values, set them to Empty
74- return new ExecutionContext ( m_localValues ?? AsyncLocalValueMap . Empty , m_localChangeNotifications ?? Array . Empty < IAsyncLocal > ( ) , isFlowSuppressed ) ;
74+
75+ return new ExecutionContext ( m_localValues , m_localChangeNotifications , isFlowSuppressed ) ;
7576 }
7677
7778 public static AsyncFlowControl SuppressFlow ( )
0 commit comments