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

◆ FromAsyncImpl< TArg1 >()

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

Definition at line 382 of file TaskFactory.cs.

383 {
384 if (beginMethod == null)
385 {
386 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.beginMethod);
387 }
388 if (endFunction == null && endAction == null)
389 {
390 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.endFunction);
391 }
392 TaskFactory.CheckFromAsyncOptions(creationOptions, hasBeginMethod: true);
394 if (TplEventSource.Log.IsEnabled())
395 {
396 TplEventSource.Log.TraceOperationBegin(promise.Id, "TaskFactory.FromAsync: " + beginMethod.Method.Name, 0L);
397 }
398 if (Task.s_asyncDebuggingEnabled)
399 {
400 Task.AddToActiveTasks(promise);
401 }
402 try
403 {
404 IAsyncResult asyncResult = beginMethod(arg1, delegate(IAsyncResult iar)
405 {
406 if (!iar.CompletedSynchronously)
407 {
408 FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
409 }
410 }, state);
411 if (asyncResult.CompletedSynchronously)
412 {
414 }
415 }
416 catch
417 {
418 if (TplEventSource.Log.IsEnabled())
419 {
420 TplEventSource.Log.TraceOperationEnd(promise.Id, AsyncCausalityStatus.Error);
421 }
422 if (Task.s_asyncDebuggingEnabled)
423 {
424 Task.RemoveFromActiveTasks(promise);
425 }
426 promise.TrySetResult();
427 throw;
428 }
429 return promise;
430 }
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().