Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TaskSchedulerAwaitTaskContinuation.cs
Go to the documentation of this file.
2
4{
5 private readonly TaskScheduler m_scheduler;
6
7 internal TaskSchedulerAwaitTaskContinuation(TaskScheduler scheduler, Action action, bool flowExecutionContext)
8 : base(action, flowExecutionContext)
9 {
11 }
12
13 internal sealed override void Run(Task ignored, bool canInlineContinuationTask)
14 {
16 {
17 base.Run(ignored, canInlineContinuationTask);
18 return;
19 }
20 bool flag = canInlineContinuationTask && (TaskScheduler.InternalCurrent == m_scheduler || Thread.CurrentThread.IsThreadPoolThread);
21 Task task = CreateTask(delegate(object state)
22 {
23 try
24 {
25 ((Action)state)();
26 }
27 catch (Exception exception)
28 {
30 }
32 if (flag)
33 {
34 TaskContinuation.InlineIfPossibleOrElseQueue(task, needsProtection: false);
35 return;
36 }
37 try
38 {
39 task.ScheduleAndStart(needsProtection: false);
40 }
42 {
43 }
44 }
45}
Task CreateTask(Action< object > action, object state, TaskScheduler scheduler)
static void InlineIfPossibleOrElseQueue(Task task, bool needsProtection)
override void Run(Task ignored, bool canInlineContinuationTask)
TaskSchedulerAwaitTaskContinuation(TaskScheduler scheduler, Action action, bool flowExecutionContext)
static void ThrowAsync(Exception exception, SynchronizationContext targetContext)
Definition Task.cs:1806
static Thread CurrentThread
Definition Thread.cs:312
delegate void Action()