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

◆ WaitForCompletion() [3/3]

object System.Net.LazyAsyncResult.WaitForCompletion ( bool snap)
inlineprivateinherited

Definition at line 249 of file LazyAsyncResult.cs.

250 {
251 ManualResetEvent waitHandle = null;
252 bool flag = false;
253 if (!(snap ? IsCompleted : InternalPeekCompleted))
254 {
255 waitHandle = (ManualResetEvent)_event;
256 if (waitHandle == null)
257 {
258 flag = LazilyCreateEvent(out waitHandle);
259 }
260 }
261 if (waitHandle != null)
262 {
263 try
264 {
265 if (System.Net.NetEventSource.Log.IsEnabled())
266 {
267 System.Net.NetEventSource.Info(this, $"Waiting for completion event {waitHandle}", "WaitForCompletion");
268 }
269 waitHandle.WaitOne(-1);
270 }
271 catch (ObjectDisposedException)
272 {
273 }
274 finally
275 {
276 if (flag && !_userEvent)
277 {
278 ManualResetEvent manualResetEvent = (ManualResetEvent)_event;
279 _event = null;
280 if (!_userEvent)
281 {
282 manualResetEvent?.Dispose();
283 }
284 }
285 }
286 }
287 SpinWait spinWait = default(SpinWait);
288 while (_result == DBNull.Value)
289 {
290 spinWait.SpinOnce();
291 }
292 return _result;
293 }
bool LazilyCreateEvent(out ManualResetEvent waitHandle)
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
virtual void Dispose(bool explicitDisposing)
virtual bool WaitOne(int millisecondsTimeout)

References System.Net.LazyAsyncResult._event, System.Net.LazyAsyncResult._result, System.Net.LazyAsyncResult._userEvent, System.Threading.WaitHandle.Dispose(), System.Net.NetEventSource.Info(), System.Net.LazyAsyncResult.InternalPeekCompleted, System.Net.LazyAsyncResult.IsCompleted, System.Net.LazyAsyncResult.LazilyCreateEvent(), System.Net.NetEventSource.Log, System.Threading.SpinWait.SpinOnce(), System.DBNull.Value, and System.Threading.WaitHandle.WaitOne().