Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CaptureOrComplete() [2/2]

bool System.Net.ContextAwareResult.CaptureOrComplete ( ref ExecutionContext cachedContext,
bool returnContext )
inlineprivate

Definition at line 87 of file ContextAwareResult.cs.

88 {
89 bool flag = base.AsyncCallback != null || (_flags & StateFlags.CaptureContext) != 0;
90 if ((_flags & StateFlags.CaptureIdentity) != 0 && !base.InternalPeekCompleted && !flag)
91 {
92 if (System.Net.NetEventSource.Log.IsEnabled())
93 {
94 System.Net.NetEventSource.Info(this, "starting identity capture", "CaptureOrComplete");
95 }
97 }
98 if (flag && !base.InternalPeekCompleted)
99 {
100 if (System.Net.NetEventSource.Log.IsEnabled())
101 {
102 System.Net.NetEventSource.Info(this, "starting capture", "CaptureOrComplete");
103 }
104 if (cachedContext == null)
105 {
106 cachedContext = ExecutionContext.Capture();
107 }
108 if (cachedContext != null)
109 {
110 if (!returnContext)
111 {
112 _context = cachedContext;
113 cachedContext = null;
114 }
115 else
116 {
117 _context = cachedContext;
118 }
119 }
120 if (System.Net.NetEventSource.Log.IsEnabled())
121 {
122 System.Net.NetEventSource.Info(this, $"_context:{_context}", "CaptureOrComplete");
123 }
124 }
125 else
126 {
127 if (System.Net.NetEventSource.Log.IsEnabled())
128 {
129 System.Net.NetEventSource.Info(this, "Skipping capture", "CaptureOrComplete");
130 }
131 cachedContext = null;
132 }
133 if (base.CompletedSynchronously)
134 {
135 if (System.Net.NetEventSource.Log.IsEnabled())
136 {
137 System.Net.NetEventSource.Info(this, "Completing synchronously", "CaptureOrComplete");
138 }
139 base.Complete(IntPtr.Zero);
140 return true;
141 }
142 return false;
143 }
volatile ExecutionContext _context
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static ? ExecutionContext Capture()

References System.Net.ContextAwareResult._context, System.Net.ContextAwareResult._flags, System.Threading.ExecutionContext.Capture(), System.Net.NetEventSource.Info(), System.Net.NetEventSource.Log, System.Net.ContextAwareResult.SafeCaptureIdentity(), and System.IntPtr.Zero.