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

◆ ChooseCoreByLinking< T1, T2, T3 >()

static Task< int > System.Threading.Tasks.Dataflow.DataflowBlock.ChooseCoreByLinking< T1, T2, T3 > ( ISourceBlock< T1 > source1,
Action< T1 > action1,
ISourceBlock< T2 > source2,
Action< T2 > action2,
ISourceBlock< T3 > source3,
Action< T3 > action3,
DataflowBlockOptions dataflowBlockOptions )
inlinestaticprivate

Definition at line 1611 of file DataflowBlock.cs.

1612 {
1613 bool flag = source3 != null;
1615 CancellationTokenSource cts = CancellationTokenSource.CreateLinkedTokenSource(dataflowBlockOptions.CancellationToken, CancellationToken.None);
1616 TaskScheduler taskScheduler = dataflowBlockOptions.TaskScheduler;
1617 Task<int>[] array = new Task<int>[flag ? 3 : 2];
1620 if (flag)
1621 {
1623 }
1625 Task.Factory.ContinueWhenAll(array, delegate(Task<int>[] tasks)
1626 {
1627 List<Exception> list = null;
1628 int num = -1;
1629 foreach (Task<int> task in tasks)
1630 {
1631 switch (task.Status)
1632 {
1633 case TaskStatus.Faulted:
1634 Common.AddException(ref list, task.Exception, unwrapInnerExceptions: true);
1635 break;
1636 case TaskStatus.RanToCompletion:
1637 {
1638 int result2 = task.Result;
1639 if (result2 >= 0)
1640 {
1641 num = result2;
1642 }
1643 break;
1644 }
1645 }
1646 }
1647 if (list != null)
1648 {
1649 result.TrySetException(list);
1650 }
1651 else if (num >= 0)
1652 {
1653 result.TrySetResult(num);
1654 }
1655 else
1656 {
1657 result.TrySetCanceled();
1658 }
1659 cts.Dispose();
1660 }, CancellationToken.None, Common.GetContinuationOptions(), TaskScheduler.Default);
1661 return result.Task;
1662 }
static TaskContinuationOptions GetContinuationOptions(TaskContinuationOptions toInclude=TaskContinuationOptions.None)
Definition Common.cs:262

References System.array, System.Threading.CancellationTokenSource.CreateLinkedTokenSource(), System.Threading.Tasks.Task< TResult >.Factory, System.list, System.Threading.CancellationToken.None, System.task, and System.tasks.