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

◆ FromAsyncImpl() [1/2]

static Task< TResult > System.Threading.Tasks.TaskFactory< TResult >.FromAsyncImpl ( Func< AsyncCallback, object, IAsyncResult > beginMethod,
Func< IAsyncResult, TResult > endFunction,
Action< IAsyncResult > endAction,
object state,
TaskCreationOptions creationOptions )
inlinestaticpackage

Definition at line 322 of file TaskFactory.cs.

323 {
324 if (beginMethod == null)
325 {
326 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.beginMethod);
327 }
328 if (endFunction == null && endAction == null)
329 {
330 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.endMethod);
331 }
332 TaskFactory.CheckFromAsyncOptions(creationOptions, hasBeginMethod: true);
334 if (TplEventSource.Log.IsEnabled())
335 {
336 TplEventSource.Log.TraceOperationBegin(promise.Id, "TaskFactory.FromAsync: " + beginMethod.Method.Name, 0L);
337 }
338 if (Task.s_asyncDebuggingEnabled)
339 {
340 Task.AddToActiveTasks(promise);
341 }
342 try
343 {
344 IAsyncResult asyncResult = beginMethod(delegate(IAsyncResult iar)
345 {
346 if (!iar.CompletedSynchronously)
347 {
348 FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
349 }
350 }, state);
351 if (asyncResult.CompletedSynchronously)
352 {
354 }
355 }
356 catch
357 {
358 if (TplEventSource.Log.IsEnabled())
359 {
360 TplEventSource.Log.TraceOperationEnd(promise.Id, AsyncCausalityStatus.Error);
361 }
362 if (Task.s_asyncDebuggingEnabled)
363 {
364 Task.RemoveFromActiveTasks(promise);
365 }
366 promise.TrySetResult();
367 throw;
368 }
369 return promise;
370 }
static void FromAsyncCoreLogic(IAsyncResult iar, Func< IAsyncResult, TResult > endFunction, Action< IAsyncResult > endAction, Task< TResult > promise, bool requiresSynchronization)

References System.Threading.Tasks.Task< TResult >.AddToActiveTasks(), System.asyncResult, System.beginMethod, System.Threading.Tasks.TaskFactory< TResult >.CheckFromAsyncOptions(), System.creationOptions, System.endFunction, System.Threading.Tasks.TplEventSource.Log, System.Threading.Tasks.Task< TResult >.RemoveFromActiveTasks(), System.Threading.Tasks.Task< TResult >.s_asyncDebuggingEnabled, System.state, and System.ThrowHelper.ThrowArgumentNullException().