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

◆ FromAsyncImpl< TArg1, TArg2 >()

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

Definition at line 442 of file TaskFactory.cs.

443 {
444 if (beginMethod == null)
445 {
446 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.beginMethod);
447 }
448 if (endFunction == null && endAction == null)
449 {
450 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.endMethod);
451 }
452 TaskFactory.CheckFromAsyncOptions(creationOptions, hasBeginMethod: true);
454 if (TplEventSource.Log.IsEnabled())
455 {
456 TplEventSource.Log.TraceOperationBegin(promise.Id, "TaskFactory.FromAsync: " + beginMethod.Method.Name, 0L);
457 }
458 if (Task.s_asyncDebuggingEnabled)
459 {
460 Task.AddToActiveTasks(promise);
461 }
462 try
463 {
464 IAsyncResult asyncResult = beginMethod(arg1, arg2, delegate(IAsyncResult iar)
465 {
466 if (!iar.CompletedSynchronously)
467 {
468 FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
469 }
470 }, state);
471 if (asyncResult.CompletedSynchronously)
472 {
474 }
475 }
476 catch
477 {
478 if (TplEventSource.Log.IsEnabled())
479 {
480 TplEventSource.Log.TraceOperationEnd(promise.Id, AsyncCausalityStatus.Error);
481 }
482 if (Task.s_asyncDebuggingEnabled)
483 {
484 Task.RemoveFromActiveTasks(promise);
485 }
486 promise.TrySetResult();
487 throw;
488 }
489 return promise;
490 }
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().