[corlib] Small part of thread from reference sources
[mono.git] / mcs / class / corlib / ReferenceSources / ExecutionContext.cs
1
2 using System.Security;
3
4 namespace System.Threading
5 {
6         partial class ExecutionContext
7         {
8                 internal static ExecutionContext Capture (ref StackCrawlMark stackMark, CaptureOptions options)
9                 {
10                         return Capture ((options & CaptureOptions.IgnoreSyncCtx) == 0, false);
11                 }
12
13                 internal static ExecutionContext FastCapture()
14                 {
15                         return Capture ();
16                 }
17
18                 [Flags]
19                 internal enum CaptureOptions
20                 {
21                         None = 0x00,
22
23                         IgnoreSyncCtx = 0x01,       //Don't flow SynchronizationContext
24
25                         OptimizeDefaultCase = 0x02, //Faster in the typical case, but can't show the result to users
26                                                     // because they could modify the shared default EC.
27                                                     // Use this only if you won't be exposing the captured EC to users.
28                 }
29
30                 private static readonly ExecutionContext s_dummyDefaultEC = new ExecutionContext();
31                 static internal ExecutionContext PreAllocatedDefault
32                 {
33                         [SecuritySafeCritical]
34                         get {
35                                 return s_dummyDefaultEC;
36                         }
37                 }
38
39                 internal bool IsPreAllocatedDefault
40                 {
41                         get
42                         {
43                                 return this == s_dummyDefaultEC;
44                         }
45                 }
46         }
47 }