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

◆ FromAsyncImpl< TArg1, TArg2, TArg3 >()

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

Definition at line 502 of file TaskFactory.cs.

503 {
504 if (beginMethod == null)
505 {
506 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.beginMethod);
507 }
508 if (endFunction == null && endAction == null)
509 {
510 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.endMethod);
511 }
512 TaskFactory.CheckFromAsyncOptions(creationOptions, hasBeginMethod: true);
514 if (TplEventSource.Log.IsEnabled())
515 {
516 TplEventSource.Log.TraceOperationBegin(promise.Id, "TaskFactory.FromAsync: " + beginMethod.Method.Name, 0L);
517 }
518 if (Task.s_asyncDebuggingEnabled)
519 {
520 Task.AddToActiveTasks(promise);
521 }
522 try
523 {
524 IAsyncResult asyncResult = beginMethod(arg1, arg2, arg3, delegate(IAsyncResult iar)
525 {
526 if (!iar.CompletedSynchronously)
527 {
528 FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
529 }
530 }, state);
531 if (asyncResult.CompletedSynchronously)
532 {
534 }
535 }
536 catch
537 {
538 if (TplEventSource.Log.IsEnabled())
539 {
540 TplEventSource.Log.TraceOperationEnd(promise.Id, AsyncCausalityStatus.Error);
541 }
542 if (Task.s_asyncDebuggingEnabled)
543 {
544 Task.RemoveFromActiveTasks(promise);
545 }
546 promise.TrySetResult();
547 throw;
548 }
549 return promise;
550 }
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().