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

◆ ExecuteWithThreadLocal()

void System.Threading.Tasks.Task< TResult >.ExecuteWithThreadLocal ( ref Task< TResult > currentTaskSlot,
Thread threadPoolThread = null )
inlineprivateinherited

Definition at line 2046 of file Task.cs.

2047 {
2049 TplEventSource log = TplEventSource.Log;
2051 bool flag = log.IsEnabled();
2052 if (flag)
2053 {
2054 if (log.TasksSetActivityIds)
2055 {
2056 EventSource.SetCurrentThreadActivityId(TplEventSource.CreateGuidForTaskID(Id), out oldActivityThatWillContinue);
2057 }
2058 if (task != null)
2059 {
2060 log.TaskStarted(task.m_taskScheduler.Id, task.Id, Id);
2061 }
2062 else
2063 {
2064 log.TaskStarted(TaskScheduler.Current.Id, 0, Id);
2065 }
2066 log.TraceSynchronousWorkBegin(Id, CausalitySynchronousWork.Execution);
2067 }
2068 try
2069 {
2070 currentTaskSlot = this;
2071 try
2072 {
2073 ExecutionContext capturedContext = CapturedContext;
2074 if (capturedContext == null)
2075 {
2076 InnerInvoke();
2077 }
2078 else if (threadPoolThread == null)
2079 {
2080 ExecutionContext.RunInternal(capturedContext, s_ecCallback, this);
2081 }
2082 else
2083 {
2084 ExecutionContext.RunFromThreadPoolDispatchLoop(threadPoolThread, capturedContext, s_ecCallback, this);
2085 }
2086 }
2088 {
2090 }
2091 if (flag)
2092 {
2093 log.TraceSynchronousWorkEnd(CausalitySynchronousWork.Execution);
2094 }
2096 }
2097 finally
2098 {
2100 if (flag)
2101 {
2102 if (task != null)
2103 {
2104 log.TaskCompleted(task.m_taskScheduler.Id, task.Id, Id, IsFaulted);
2105 }
2106 else
2107 {
2108 log.TaskCompleted(TaskScheduler.Current.Id, 0, Id, IsFaulted);
2109 }
2110 if (log.TasksSetActivityIds)
2111 {
2113 }
2114 }
2115 }
2116 }
static void SetCurrentThreadActivityId(Guid activityId)
ExecutionContext? CapturedContext
Definition Task.cs:1160
void HandleException(Exception unhandledException)
Definition Task.cs:2130
void Finish(bool userDelegateExecute)
Definition Task.cs:1839
AggregateException? Exception
Definition Task.cs:1014
override void InnerInvoke()
Definition Task.cs:209
static readonly ContextCallback s_ecCallback
Definition Task.cs:968

References System.Threading.Tasks.Task< TResult >.CapturedContext, System.Threading.Tasks.TplEventSource.CreateGuidForTaskID(), System.Threading.Tasks.TaskScheduler.Current, System.Threading.Tasks.Task< TResult >.Finish(), System.Threading.Tasks.Task< TResult >.HandleException(), System.Threading.Tasks.Task< TResult >.Id, System.Threading.Tasks.Task< TResult >.InnerInvoke(), System.Threading.Tasks.Task< TResult >.IsFaulted, System.Threading.Tasks.TplEventSource.Log, System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(), System.Threading.ExecutionContext.RunInternal(), System.Threading.Tasks.Task< TResult >.s_ecCallback, System.Diagnostics.Tracing.EventSource.SetCurrentThreadActivityId(), and System.task.

Referenced by System.Threading.Tasks.Task< TResult >.ExecuteEntry(), and System.Threading.Tasks.Task< TResult >.ExecuteEntryUnsafe().