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

◆ RunAsync< TResult >()

static Task< TResult > System.Net.Dns.RunAsync< TResult > ( Func< object, ValueStopwatch, TResult > func,
object key,
CancellationToken cancellationToken )
inlinestaticprivate

Definition at line 605 of file Dns.cs.

606 {
607 ValueStopwatch stopwatch = NameResolutionTelemetry.Log.BeforeResolution(key);
608 Task<TResult> task2 = null;
609 lock (s_tasks)
610 {
611 s_tasks.TryGetValue(key, out var value);
612 if (value == null)
613 {
615 }
616 task2 = value.ContinueWith(delegate
617 {
618 try
619 {
620 return func(key, stopwatch);
621 }
622 finally
623 {
624 lock (s_tasks)
625 {
627 }
628 }
630 if (cancellationToken.CanBeCanceled)
631 {
632 task2.ContinueWith(delegate(Task<TResult> task, object key)
633 {
634 lock (s_tasks)
635 {
637 }
638 }, key, CancellationToken.None, TaskContinuationOptions.OnlyOnCanceled | TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);
639 }
640 s_tasks[key] = task2;
641 }
642 return task2;
643 }
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
static readonly Dictionary< object, Task > s_tasks
Definition Dns.cs:14
static Task CompletedTask
Definition Task.cs:1120

References System.cancellationToken, System.Threading.Tasks.Task< TResult >.CompletedTask, System.Threading.Tasks.TaskScheduler.Default, System.key, System.Net.NameResolutionTelemetry.Log, System.Threading.CancellationToken.None, System.Collections.Generic.Dictionary< TKey, TValue >.Remove(), System.Net.Dns.s_tasks, System.task, and System.value.