Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
QueryTaskGroupState.cs
Go to the documentation of this file.
3
5
6internal sealed class QueryTaskGroupState
7{
8 private Task _rootTask;
9
10 private int _alreadyEnded;
11
13
14 private readonly int _queryId;
15
16 internal bool IsAlreadyEnded => _alreadyEnded == 1;
17
19
20 internal int QueryId => _queryId;
21
22 internal QueryTaskGroupState(CancellationState cancellationState, int queryId)
23 {
24 _cancellationState = cancellationState;
25 _queryId = queryId;
26 }
27
28 internal void QueryBegin(Task rootTask)
29 {
30 _rootTask = rootTask;
31 }
32
33 internal void QueryEnd(bool userInitiatedDispose)
34 {
35 if (Interlocked.Exchange(ref _alreadyEnded, 1) != 0)
36 {
37 return;
38 }
39 try
40 {
42 }
43 catch (AggregateException ex)
44 {
45 AggregateException ex2 = ex.Flatten();
46 bool flag = true;
47 for (int i = 0; i < ex2.InnerExceptions.Count; i++)
48 {
49 if (!(ex2.InnerExceptions[i] is OperationCanceledException { CancellationToken: { IsCancellationRequested: not false } } ex3) || ex3.CancellationToken != _cancellationState.ExternalCancellationToken)
50 {
51 flag = false;
52 break;
53 }
54 }
55 if (!flag || ex2.InnerExceptions.Count == 0)
56 {
57 throw ex2;
58 }
59 }
60 finally
61 {
62 ((IDisposable)_rootTask)?.Dispose();
63 }
65 {
67 {
69 }
70 if (!userInitiatedDispose)
71 {
73 }
74 }
75 }
76}
ReadOnlyCollection< Exception > InnerExceptions
AggregateException Flatten()
static void ThrowWithStandardMessageIfCanceled(CancellationToken externalCancellationToken)
void QueryEnd(bool userInitiatedDispose)
readonly CancellationState _cancellationState
QueryTaskGroupState(CancellationState cancellationState, int queryId)
static string PLINQ_DisposeRequested
Definition SR.cs:28
Definition SR.cs:7
static int Exchange(ref int location1, int value)