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

◆ Run< TState >()

static void System.Threading.Tasks.TaskReplicator.Run< TState > ( ReplicatableUserAction< TState > action,
ParallelOptions options,
bool stopOnFirstFailure )
inlinestatic

Definition at line 125 of file TaskReplicator.cs.

126 {
127 if (OperatingSystem.IsBrowser())
128 {
129 int timeout = 2147483646;
130 TState replicaState = default(TState);
131 action(ref replicaState, timeout, out var yieldedBeforeCompletion);
132 if (yieldedBeforeCompletion)
133 {
134 throw new Exception("Replicated tasks cannot yield in this single-threaded browser environment");
135 }
136 return;
137 }
138 int maxConcurrency = ((options.EffectiveMaxConcurrencyLevel > 0) ? options.EffectiveMaxConcurrencyLevel : int.MaxValue);
139 TaskReplicator taskReplicator = new TaskReplicator(options, stopOnFirstFailure);
140 new Replica<TState>(taskReplicator, maxConcurrency, 1073741823, action).Start();
141 Replica result;
142 while (taskReplicator._pendingReplicas.TryDequeue(out result))
143 {
144 result.Wait();
145 }
146 if (taskReplicator._exceptions != null)
147 {
148 throw new AggregateException(taskReplicator._exceptions);
149 }
150 }
TaskReplicator(ParallelOptions options, bool stopOnFirstFailure)

References System.Threading.Tasks.TaskReplicator.TaskReplicator(), System.Threading.Tasks.TaskReplicator._exceptions, System.Threading.Tasks.TaskReplicator._pendingReplicas, System.action, System.OperatingSystem.IsBrowser(), System.options, System.Threading.Tasks.TaskReplicator.Replica< TState >.Start(), System.timeout, and System.Threading.Tasks.TaskReplicator.Replica< TState >.Wait().