mscorlib(4.0.0.0) API with additions
ExecutionContext.cs
7 using System.Security;
8 
9 namespace System.Threading
10 {
12  [Serializable]
13  [__DynamicallyInvokable]
15  {
16  private enum Flags
17  {
18  None = 0,
19  IsNewCapture = 1,
20  IsFlowSuppressed = 2,
21  IsPreAllocatedDefault = 4
22  }
23 
24  internal struct Reader
25  {
26  private ExecutionContext m_ec;
27 
28  public bool IsNull => m_ec == null;
29 
30  public bool IsFlowSuppressed
31  {
32  [MethodImpl(MethodImplOptions.AggressiveInlining)]
33  get
34  {
35  if (!IsNull)
36  {
37  return m_ec.isFlowSuppressed;
38  }
39  return false;
40  }
41  }
42 
44  {
45  get
46  {
47  if (!IsNull)
48  {
49  return m_ec.SynchronizationContext;
50  }
51  return null;
52  }
53  }
54 
55  public SynchronizationContext SynchronizationContextNoFlow
56  {
57  get
58  {
59  if (!IsNull)
60  {
61  return m_ec.SynchronizationContextNoFlow;
62  }
63  return null;
64  }
65  }
66 
68  {
69  [MethodImpl(MethodImplOptions.AggressiveInlining)]
70  [SecurityCritical]
71  get
72  {
73  return new SecurityContext.Reader(IsNull ? null : m_ec.SecurityContext);
74  }
75  }
76 
78  {
79  [SecurityCritical]
80  get
81  {
82  return new LogicalCallContext.Reader(IsNull ? null : m_ec.LogicalCallContext);
83  }
84  }
85 
86  public IllogicalCallContext.Reader IllogicalCallContext
87  {
88  [SecurityCritical]
89  get
90  {
91  return new IllogicalCallContext.Reader(IsNull ? null : m_ec.IllogicalCallContext);
92  }
93  }
94 
95  public Reader(ExecutionContext ec)
96  {
97  m_ec = ec;
98  }
99 
100  public ExecutionContext DangerousGetRawExecutionContext()
101  {
102  return m_ec;
103  }
104 
105  [SecurityCritical]
106  public bool IsDefaultFTContext(bool ignoreSyncCtx)
107  {
108  return m_ec.IsDefaultFTContext(ignoreSyncCtx);
109  }
110 
111  public bool IsSame(Reader other)
112  {
113  return m_ec == other.m_ec;
114  }
115 
116  [SecurityCritical]
117  public object GetLocalValue(IAsyncLocal local)
118  {
119  if (IsNull)
120  {
121  return null;
122  }
123  if (m_ec._localValues == null)
124  {
125  return null;
126  }
127  m_ec._localValues.TryGetValue(local, out object value);
128  return value;
129  }
130 
131  [SecurityCritical]
132  public bool HasSameLocalValues(ExecutionContext other)
133  {
134  Dictionary<IAsyncLocal, object> dictionary = IsNull ? null : m_ec._localValues;
135  Dictionary<IAsyncLocal, object> dictionary2 = other?._localValues;
136  return dictionary == dictionary2;
137  }
138 
139  [SecurityCritical]
140  public bool HasLocalValues()
141  {
142  if (!IsNull)
143  {
144  return m_ec._localValues != null;
145  }
146  return false;
147  }
148  }
149 
150  [Flags]
151  internal enum CaptureOptions
152  {
153  None = 0x0,
154  IgnoreSyncCtx = 0x1,
155  OptimizeDefaultCase = 0x2
156  }
157 
158  private HostExecutionContext _hostExecutionContext;
159 
160  private SynchronizationContext _syncContext;
161 
162  private SynchronizationContext _syncContextNoFlow;
163 
164  private SecurityContext _securityContext;
165 
166  [SecurityCritical]
167  private LogicalCallContext _logicalCallContext;
168 
169  private IllogicalCallContext _illogicalCallContext;
170 
171  private Flags _flags;
172 
173  private Dictionary<IAsyncLocal, object> _localValues;
174 
175  private List<IAsyncLocal> _localChangeNotifications;
176 
177  private static readonly ExecutionContext s_dummyDefaultEC = new ExecutionContext(isPreAllocatedDefault: true);
178 
179  internal bool isNewCapture
180  {
181  get
182  {
183  return (_flags & (Flags)5) != Flags.None;
184  }
185  set
186  {
187  if (value)
188  {
189  _flags |= Flags.IsNewCapture;
190  }
191  else
192  {
193  _flags &= (Flags)(-2);
194  }
195  }
196  }
197 
198  internal bool isFlowSuppressed
199  {
200  get
201  {
202  return (_flags & Flags.IsFlowSuppressed) != Flags.None;
203  }
204  set
205  {
206  if (value)
207  {
208  _flags |= Flags.IsFlowSuppressed;
209  }
210  else
211  {
212  _flags &= (Flags)(-3);
213  }
214  }
215  }
216 
217  internal static ExecutionContext PreAllocatedDefault
218  {
219  [SecuritySafeCritical]
220  get
221  {
222  return s_dummyDefaultEC;
223  }
224  }
225 
226  internal bool IsPreAllocatedDefault
227  {
228  get
229  {
230  if ((_flags & Flags.IsPreAllocatedDefault) != 0)
231  {
232  return true;
233  }
234  return false;
235  }
236  }
237 
239  {
240  [SecurityCritical]
241  get
242  {
243  if (_logicalCallContext == null)
244  {
245  _logicalCallContext = new LogicalCallContext();
246  }
247  return _logicalCallContext;
248  }
249  [SecurityCritical]
250  set
251  {
252  _logicalCallContext = value;
253  }
254  }
255 
256  internal IllogicalCallContext IllogicalCallContext
257  {
258  get
259  {
260  if (_illogicalCallContext == null)
261  {
262  _illogicalCallContext = new IllogicalCallContext();
263  }
264  return _illogicalCallContext;
265  }
266  set
267  {
268  _illogicalCallContext = value;
269  }
270  }
271 
273  {
274  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
275  get
276  {
277  return _syncContext;
278  }
279  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
280  set
281  {
282  _syncContext = value;
283  }
284  }
285 
286  internal SynchronizationContext SynchronizationContextNoFlow
287  {
288  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
289  get
290  {
291  return _syncContextNoFlow;
292  }
293  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
294  set
295  {
296  _syncContextNoFlow = value;
297  }
298  }
299 
301  {
302  get
303  {
304  return _hostExecutionContext;
305  }
306  set
307  {
308  _hostExecutionContext = value;
309  }
310  }
311 
313  {
314  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
315  get
316  {
317  return _securityContext;
318  }
319  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
320  set
321  {
322  _securityContext = value;
323  if (value != null)
324  {
325  _securityContext.ExecutionContext = this;
326  }
327  }
328  }
329 
330  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
331  internal ExecutionContext()
332  {
333  }
334 
335  [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
336  internal ExecutionContext(bool isPreAllocatedDefault)
337  {
338  if (isPreAllocatedDefault)
339  {
340  _flags = Flags.IsPreAllocatedDefault;
341  }
342  }
343 
344  [SecurityCritical]
345  internal static object GetLocalValue(IAsyncLocal local)
346  {
347  return Thread.CurrentThread.GetExecutionContextReader().GetLocalValue(local);
348  }
349 
350  [SecurityCritical]
351  internal static void SetLocalValue(IAsyncLocal local, object newValue, bool needChangeNotifications)
352  {
353  ExecutionContext mutableExecutionContext = Thread.CurrentThread.GetMutableExecutionContext();
354  object value = null;
355  bool flag = mutableExecutionContext._localValues != null && mutableExecutionContext._localValues.TryGetValue(local, out value);
356  if (value == newValue)
357  {
358  return;
359  }
360  if (mutableExecutionContext._localValues == null)
361  {
362  mutableExecutionContext._localValues = new Dictionary<IAsyncLocal, object>();
363  }
364  else
365  {
366  mutableExecutionContext._localValues = new Dictionary<IAsyncLocal, object>(mutableExecutionContext._localValues);
367  }
368  mutableExecutionContext._localValues[local] = newValue;
369  if (!needChangeNotifications)
370  {
371  return;
372  }
373  if (!flag)
374  {
375  if (mutableExecutionContext._localChangeNotifications == null)
376  {
377  mutableExecutionContext._localChangeNotifications = new List<IAsyncLocal>();
378  }
379  else
380  {
381  mutableExecutionContext._localChangeNotifications = new List<IAsyncLocal>(mutableExecutionContext._localChangeNotifications);
382  }
383  mutableExecutionContext._localChangeNotifications.Add(local);
384  }
385  local.OnValueChanged(value, newValue, contextChanged: false);
386  }
387 
388  [SecurityCritical]
389  [HandleProcessCorruptedStateExceptions]
390  internal static void OnAsyncLocalContextChanged(ExecutionContext previous, ExecutionContext current)
391  {
392  List<IAsyncLocal> list = previous?._localChangeNotifications;
393  if (list != null)
394  {
395  foreach (IAsyncLocal item in list)
396  {
397  object value = null;
398  if (previous != null && previous._localValues != null)
399  {
400  previous._localValues.TryGetValue(item, out value);
401  }
402  object value2 = null;
403  if (current != null && current._localValues != null)
404  {
405  current._localValues.TryGetValue(item, out value2);
406  }
407  if (value != value2)
408  {
409  item.OnValueChanged(value, value2, contextChanged: true);
410  }
411  }
412  }
413  List<IAsyncLocal> list2 = current?._localChangeNotifications;
414  if (list2 != null && list2 != list)
415  {
416  try
417  {
418  foreach (IAsyncLocal item2 in list2)
419  {
420  object value3 = null;
421  if (previous == null || previous._localValues == null || !previous._localValues.TryGetValue(item2, out value3))
422  {
423  object value4 = null;
424  if (current != null && current._localValues != null)
425  {
426  current._localValues.TryGetValue(item2, out value4);
427  }
428  if (value3 != value4)
429  {
430  item2.OnValueChanged(value3, value4, contextChanged: true);
431  }
432  }
433  }
434  }
435  catch (Exception exception)
436  {
437  Environment.FailFast(Environment.GetResourceString("ExecutionContext_ExceptionInAsyncLocalNotification"), exception);
438  }
439  }
440  }
441 
443  public void Dispose()
444  {
445  if (!IsPreAllocatedDefault)
446  {
447  if (_hostExecutionContext != null)
448  {
449  _hostExecutionContext.Dispose();
450  }
451  if (_securityContext != null)
452  {
453  _securityContext.Dispose();
454  }
455  }
456  }
457 
466  [SecurityCritical]
467  [__DynamicallyInvokable]
468  public static void Run(ExecutionContext executionContext, ContextCallback callback, object state)
469  {
470  if (executionContext == null)
471  {
472  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NullContext"));
473  }
474  if (!executionContext.isNewCapture)
475  {
476  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotNewCaptureContext"));
477  }
478  Run(executionContext, callback, state, preserveSyncCtx: false);
479  }
480 
481  [SecurityCritical]
482  [FriendAccessAllowed]
483  internal static void Run(ExecutionContext executionContext, ContextCallback callback, object state, bool preserveSyncCtx)
484  {
485  RunInternal(executionContext, callback, state, preserveSyncCtx);
486  }
487 
488  [SecurityCritical]
489  [HandleProcessCorruptedStateExceptions]
490  internal static void RunInternal(ExecutionContext executionContext, ContextCallback callback, object state, bool preserveSyncCtx)
491  {
492  if (!executionContext.IsPreAllocatedDefault)
493  {
494  executionContext.isNewCapture = false;
495  }
496  Thread currentThread = Thread.CurrentThread;
497  ExecutionContextSwitcher ecsw = default(ExecutionContextSwitcher);
499  try
500  {
501  Reader executionContextReader = currentThread.GetExecutionContextReader();
502  if ((executionContextReader.IsNull || executionContextReader.IsDefaultFTContext(preserveSyncCtx)) && SecurityContext.CurrentlyInDefaultFTSecurityContext(executionContextReader) && executionContext.IsDefaultFTContext(preserveSyncCtx) && executionContextReader.HasSameLocalValues(executionContext))
503  {
504  EstablishCopyOnWriteScope(currentThread, knownNullWindowsIdentity: true, ref ecsw);
505  }
506  else
507  {
508  if (executionContext.IsPreAllocatedDefault)
509  {
510  executionContext = new ExecutionContext();
511  }
512  ecsw = SetExecutionContext(executionContext, preserveSyncCtx);
513  }
514  callback(state);
515  }
516  finally
517  {
518  ecsw.Undo();
519  }
520  }
521 
522  [SecurityCritical]
523  internal static void EstablishCopyOnWriteScope(ref ExecutionContextSwitcher ecsw)
524  {
525  EstablishCopyOnWriteScope(Thread.CurrentThread, knownNullWindowsIdentity: false, ref ecsw);
526  }
527 
528  [SecurityCritical]
529  private static void EstablishCopyOnWriteScope(Thread currentThread, bool knownNullWindowsIdentity, ref ExecutionContextSwitcher ecsw)
530  {
531  ecsw.outerEC = currentThread.GetExecutionContextReader();
532  ecsw.outerECBelongsToScope = currentThread.ExecutionContextBelongsToCurrentScope;
533  ecsw.cachedAlwaysFlowImpersonationPolicy = SecurityContext.AlwaysFlowImpersonationPolicy;
534  if (!knownNullWindowsIdentity)
535  {
536  ecsw.wi = SecurityContext.GetCurrentWI(ecsw.outerEC, ecsw.cachedAlwaysFlowImpersonationPolicy);
537  }
538  ecsw.wiIsValid = true;
539  currentThread.ExecutionContextBelongsToCurrentScope = false;
540  ecsw.thread = currentThread;
541  }
542 
543  [MethodImpl(MethodImplOptions.NoInlining)]
544  [SecurityCritical]
545  [HandleProcessCorruptedStateExceptions]
546  internal static ExecutionContextSwitcher SetExecutionContext(ExecutionContext executionContext, bool preserveSyncCtx)
547  {
548  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
549  ExecutionContextSwitcher executionContextSwitcher = default(ExecutionContextSwitcher);
550  Thread currentThread = Thread.CurrentThread;
551  Reader executionContextReader = currentThread.GetExecutionContextReader();
552  executionContextSwitcher.thread = currentThread;
553  executionContextSwitcher.outerEC = executionContextReader;
554  executionContextSwitcher.outerECBelongsToScope = currentThread.ExecutionContextBelongsToCurrentScope;
555  if (preserveSyncCtx)
556  {
557  executionContext.SynchronizationContext = executionContextReader.SynchronizationContext;
558  }
559  executionContext.SynchronizationContextNoFlow = executionContextReader.SynchronizationContextNoFlow;
560  currentThread.SetExecutionContext(executionContext, belongsToCurrentScope: true);
562  try
563  {
564  OnAsyncLocalContextChanged(executionContextReader.DangerousGetRawExecutionContext(), executionContext);
565  SecurityContext securityContext = executionContext.SecurityContext;
566  if (securityContext != null)
567  {
568  SecurityContext.Reader securityContext2 = executionContextReader.SecurityContext;
569  executionContextSwitcher.scsw = SecurityContext.SetSecurityContext(securityContext, securityContext2, modifyCurrentExecutionContext: false, ref stackMark);
570  }
571  else if (!SecurityContext.CurrentlyInDefaultFTSecurityContext(executionContextSwitcher.outerEC))
572  {
573  SecurityContext.Reader securityContext3 = executionContextReader.SecurityContext;
574  executionContextSwitcher.scsw = SecurityContext.SetSecurityContext(SecurityContext.FullTrustSecurityContext, securityContext3, modifyCurrentExecutionContext: false, ref stackMark);
575  }
576  HostExecutionContext hostExecutionContext = executionContext.HostExecutionContext;
577  if (hostExecutionContext == null)
578  {
579  return executionContextSwitcher;
580  }
581  executionContextSwitcher.hecsw = HostExecutionContextManager.SetHostExecutionContextInternal(hostExecutionContext);
582  return executionContextSwitcher;
583  }
584  catch
585  {
586  executionContextSwitcher.UndoNoThrow();
587  throw;
588  }
589  }
590 
594  [SecuritySafeCritical]
596  {
597  if (!isNewCapture)
598  {
599  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotCopyUsedContext"));
600  }
601  ExecutionContext executionContext = new ExecutionContext();
602  executionContext.isNewCapture = true;
603  executionContext._syncContext = ((_syncContext == null) ? null : _syncContext.CreateCopy());
604  executionContext._localValues = _localValues;
605  executionContext._localChangeNotifications = _localChangeNotifications;
606  executionContext._hostExecutionContext = ((_hostExecutionContext == null) ? null : _hostExecutionContext.CreateCopy());
607  if (_securityContext != null)
608  {
609  executionContext._securityContext = _securityContext.CreateCopy();
610  executionContext._securityContext.ExecutionContext = executionContext;
611  }
612  if (_logicalCallContext != null)
613  {
614  executionContext.LogicalCallContext = (LogicalCallContext)LogicalCallContext.Clone();
615  }
616  return executionContext;
617  }
618 
619  [SecuritySafeCritical]
620  internal ExecutionContext CreateMutableCopy()
621  {
622  ExecutionContext executionContext = new ExecutionContext();
623  executionContext._syncContext = _syncContext;
624  executionContext._syncContextNoFlow = _syncContextNoFlow;
625  executionContext._hostExecutionContext = ((_hostExecutionContext == null) ? null : _hostExecutionContext.CreateCopy());
626  if (_securityContext != null)
627  {
628  executionContext._securityContext = _securityContext.CreateMutableCopy();
629  executionContext._securityContext.ExecutionContext = executionContext;
630  }
631  if (_logicalCallContext != null)
632  {
633  executionContext.LogicalCallContext = (LogicalCallContext)LogicalCallContext.Clone();
634  }
635  if (_illogicalCallContext != null)
636  {
637  executionContext.IllogicalCallContext = IllogicalCallContext.CreateCopy();
638  }
639  executionContext._localValues = _localValues;
640  executionContext._localChangeNotifications = _localChangeNotifications;
641  executionContext.isFlowSuppressed = isFlowSuppressed;
642  return executionContext;
643  }
644 
648  [SecurityCritical]
650  {
651  if (IsFlowSuppressed())
652  {
653  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotSupressFlowMultipleTimes"));
654  }
655  AsyncFlowControl result = default(AsyncFlowControl);
656  result.Setup();
657  return result;
658  }
659 
662  [SecuritySafeCritical]
663  public static void RestoreFlow()
664  {
665  ExecutionContext mutableExecutionContext = Thread.CurrentThread.GetMutableExecutionContext();
666  if (!mutableExecutionContext.isFlowSuppressed)
667  {
668  throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotRestoreUnsupressedFlow"));
669  }
670  mutableExecutionContext.isFlowSuppressed = false;
671  }
672 
676  public static bool IsFlowSuppressed()
677  {
678  return Thread.CurrentThread.GetExecutionContextReader().IsFlowSuppressed;
679  }
680 
683  [MethodImpl(MethodImplOptions.NoInlining)]
684  [SecuritySafeCritical]
685  [__DynamicallyInvokable]
686  public static ExecutionContext Capture()
687  {
688  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
689  return Capture(ref stackMark, CaptureOptions.None);
690  }
691 
692  [MethodImpl(MethodImplOptions.NoInlining)]
693  [SecuritySafeCritical]
694  [FriendAccessAllowed]
695  internal static ExecutionContext FastCapture()
696  {
697  StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
698  return Capture(ref stackMark, CaptureOptions.IgnoreSyncCtx | CaptureOptions.OptimizeDefaultCase);
699  }
700 
701  [SecurityCritical]
702  internal static ExecutionContext Capture(ref StackCrawlMark stackMark, CaptureOptions options)
703  {
704  Reader executionContextReader = Thread.CurrentThread.GetExecutionContextReader();
705  if (executionContextReader.IsFlowSuppressed)
706  {
707  return null;
708  }
709  SecurityContext securityContext = SecurityContext.Capture(executionContextReader, ref stackMark);
710  HostExecutionContext hostExecutionContext = HostExecutionContextManager.CaptureHostExecutionContext();
711  SynchronizationContext synchronizationContext = null;
712  LogicalCallContext logicalCallContext = null;
713  if (!executionContextReader.IsNull)
714  {
715  if ((options & CaptureOptions.IgnoreSyncCtx) == CaptureOptions.None)
716  {
717  synchronizationContext = ((executionContextReader.SynchronizationContext == null) ? null : executionContextReader.SynchronizationContext.CreateCopy());
718  }
719  if (executionContextReader.LogicalCallContext.HasInfo)
720  {
721  logicalCallContext = executionContextReader.LogicalCallContext.Clone();
722  }
723  }
724  Dictionary<IAsyncLocal, object> dictionary = null;
725  List<IAsyncLocal> list = null;
726  if (!executionContextReader.IsNull)
727  {
728  dictionary = executionContextReader.DangerousGetRawExecutionContext()._localValues;
729  list = executionContextReader.DangerousGetRawExecutionContext()._localChangeNotifications;
730  }
731  if ((options & CaptureOptions.OptimizeDefaultCase) != 0 && securityContext == null && hostExecutionContext == null && synchronizationContext == null && (logicalCallContext == null || !logicalCallContext.HasInfo) && dictionary == null && list == null)
732  {
733  return s_dummyDefaultEC;
734  }
735  ExecutionContext executionContext = new ExecutionContext();
736  executionContext.SecurityContext = securityContext;
737  if (executionContext.SecurityContext != null)
738  {
739  executionContext.SecurityContext.ExecutionContext = executionContext;
740  }
741  executionContext._hostExecutionContext = hostExecutionContext;
742  executionContext._syncContext = synchronizationContext;
743  executionContext.LogicalCallContext = logicalCallContext;
744  executionContext._localValues = dictionary;
745  executionContext._localChangeNotifications = list;
746  executionContext.isNewCapture = true;
747  return executionContext;
748  }
749 
755  [SecurityCritical]
757  {
758  if (info == null)
759  {
760  throw new ArgumentNullException("info");
761  }
762  if (_logicalCallContext != null)
763  {
764  info.AddValue("LogicalCallContext", _logicalCallContext, typeof(LogicalCallContext));
765  }
766  }
767 
768  [SecurityCritical]
770  {
771  SerializationInfoEnumerator enumerator = info.GetEnumerator();
772  while (enumerator.MoveNext())
773  {
774  if (enumerator.Name.Equals("LogicalCallContext"))
775  {
776  _logicalCallContext = (LogicalCallContext)enumerator.Value;
777  }
778  }
779  }
780 
781  [SecurityCritical]
782  internal bool IsDefaultFTContext(bool ignoreSyncCtx)
783  {
784  if (_hostExecutionContext != null)
785  {
786  return false;
787  }
788  if (!ignoreSyncCtx && _syncContext != null)
789  {
790  return false;
791  }
792  if (_securityContext != null && !_securityContext.IsDefaultFTSecurityContext())
793  {
794  return false;
795  }
796  if (_logicalCallContext != null && _logicalCallContext.HasInfo)
797  {
798  return false;
799  }
800  if (_illogicalCallContext != null && _illogicalCallContext.HasUserData)
801  {
802  return false;
803  }
804  return true;
805  }
806  }
807 }
static Thread CurrentThread
Gets the currently running thread.
Definition: Thread.cs:134
Encapsulates and propagates the host execution context across threads.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
ExecutionContext CreateCopy()
Creates a copy of the current execution context.
object Clone()
Creates a new object that is a copy of the current instance.
void Dispose()
Releases all resources used by the current instance of the T:System.Threading.HostExecutionContext cl...
delegate void ContextCallback(object state)
Represents a method to be called within a new context.
object Value
Gets the value of the item currently being examined.
bool HasInfo
Gets a value indicating whether the current T:System.Runtime.Remoting.Messaging.LogicalCallContext co...
Provides a mechanism for releasing unmanaged resources.To browse the .NET Framework source code for t...
Definition: IDisposable.cs:8
Definition: __Canon.cs:3
Encapsulates and propagates all security-related data for execution contexts transferred across threa...
Describes the source and destination of a given serialized stream, and provides an additional caller-...
HostExecutionContext()
Initializes a new instance of the T:System.Threading.HostExecutionContext class.
Provides the functionality to restore the migration, or flow, of the execution context between thread...
Cer
Specifies a method's behavior when called within a constrained execution region.
Definition: Cer.cs:5
SecurityContext CreateCopy()
Creates a copy of the current security context.
virtual HostExecutionContext CreateCopy()
Creates a copy of the current host execution context.
void Add(T item)
Adds an object to the end of the T:System.Collections.Generic.List`1.
Definition: List.cs:510
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
Manages the execution context for the current thread. This class cannot be inherited.
static AsyncFlowControl SuppressFlow()
Suppresses the flow of the execution context across asynchronous threads.
void GetObjectData(SerializationInfo info, StreamingContext context)
Sets the specified T:System.Runtime.Serialization.SerializationInfo object with the logical context i...
static SecurityContext Capture()
Captures the security context for the current thread.
Provides the basic functionality for propagating a synchronization context in various synchronization...
static void PrepareConstrainedRegions()
Designates a body of code as a constrained execution region (CER).
static void Run(ExecutionContext executionContext, ContextCallback callback, object state)
Runs a method in a specified execution context on the current thread.
MethodImplOptions
Defines the details of how a method is implemented.
Provides a set of properties that are carried with the execution code path during remote method calls...
virtual SynchronizationContext CreateCopy()
When overridden in a derived class, creates a copy of the synchronization context.
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
static ExecutionContext Capture()
Captures the execution context from the current thread.
Allows an object to control its own serialization and deserialization.
Definition: ISerializable.cs:8
static bool IsFlowSuppressed()
Indicates whether the flow of the execution context is currently suppressed.
Represents errors that occur during application execution.To browse the .NET Framework source code fo...
Definition: Exception.cs:22
static void RestoreFlow()
Restores the flow of the execution context across asynchronous threads.
Specifies that the class can be serialized.
string Name
Gets the name for the item currently being examined.
The exception that is thrown when a method call is invalid for the object's current state.
Consistency
Specifies a reliability contract.
Definition: Consistency.cs:5
void Dispose()
Releases all resources used by the current instance of the T:System.Threading.ExecutionContext class.
Provides a formatter-friendly mechanism for parsing the data in T:System.Runtime.Serialization....
bool TryGetValue(TKey key, out TValue value)
Gets the value associated with the specified key.
Definition: Dictionary.cs:1624
void Dispose()
Releases all resources used by the current instance of the T:System.Security.SecurityContext class.
static void FailFast(string message)
Immediately terminates a process after writing a message to the Windows Application event log,...
Provides a set of static methods and properties that provide support for compilers....
bool MoveNext()
Updates the enumerator to the next item.
Creates and controls a thread, sets its priority, and gets its status.
Definition: Thread.cs:18