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

◆ TrySetFromTask()

bool System.Threading.Tasks.UnwrapPromise< TResult >.TrySetFromTask ( Task task,
bool lookForOce )
inlineprivate

Definition at line 91 of file UnwrapPromise.cs.

92 {
93 if (TplEventSource.Log.IsEnabled())
94 {
95 TplEventSource.Log.TraceOperationRelation(base.Id, CausalityRelation.Join);
96 }
97 bool result = false;
98 switch (task.Status)
99 {
100 case TaskStatus.Canceled:
101 result = TrySetCanceled(task.CancellationToken, task.GetCancellationExceptionDispatchInfo());
102 break;
103 case TaskStatus.Faulted:
104 {
105 List<ExceptionDispatchInfo> exceptionDispatchInfos = task.GetExceptionDispatchInfos();
107 result = ((!lookForOce || exceptionDispatchInfos.Count <= 0 || (exceptionDispatchInfo = exceptionDispatchInfos[0]) == null || !(exceptionDispatchInfo.SourceException is OperationCanceledException ex)) ? TrySetException(exceptionDispatchInfos) : TrySetCanceled(ex.CancellationToken, exceptionDispatchInfo));
108 break;
109 }
110 case TaskStatus.RanToCompletion:
111 if (TplEventSource.Log.IsEnabled())
112 {
113 TplEventSource.Log.TraceOperationEnd(base.Id, AsyncCausalityStatus.Completed);
114 }
115 if (Task.s_asyncDebuggingEnabled)
116 {
117 Task.RemoveFromActiveTasks(this);
118 }
119 result = TrySetResult((task is Task<TResult> task2) ? task2.Result : default(TResult));
120 break;
121 }
122 return result;
123 }
bool TrySetCanceled(CancellationToken tokenToRecord)
Definition Task.cs:2555
bool TrySetException(object exceptionObject)
Definition Task.cs:2542

References System.Threading.Tasks.TplEventSource.Log, System.Threading.Tasks.Task< TResult >.RemoveFromActiveTasks(), System.Threading.Tasks.Task< TResult >.s_asyncDebuggingEnabled, System.task, System.Threading.Tasks.Task< TResult >.TrySetCanceled(), System.Threading.Tasks.Task< TResult >.TrySetException(), and System.Threading.Tasks.Task< TResult >.TrySetResult().

Referenced by System.Threading.Tasks.UnwrapPromise< TResult >.InvokeCore(), System.Threading.Tasks.UnwrapPromise< TResult >.ProcessCompletedOuterTask(), and System.Threading.Tasks.UnwrapPromise< TResult >.ProcessInnerTask().