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

◆ GetStateMachineBox< TStateMachine >()

static IAsyncStateMachineBox System.Runtime.CompilerServices.AsyncTaskMethodBuilder< TResult >.GetStateMachineBox< TStateMachine > ( ref TStateMachine stateMachine,
[NotNull] ref Task< TResult > taskField )
inlinestaticprivate
Type Constraints
TStateMachine :IAsyncStateMachine 

Definition at line 268 of file AsyncTaskMethodBuilder.cs.

268 : IAsyncStateMachine
269 {
270 ExecutionContext executionContext = ExecutionContext.Capture();
271 if (taskField is AsyncStateMachineBox<TStateMachine> asyncStateMachineBox)
272 {
273 if (asyncStateMachineBox.Context != executionContext)
274 {
275 asyncStateMachineBox.Context = executionContext;
276 }
277 return asyncStateMachineBox;
278 }
279 if (taskField is AsyncStateMachineBox<IAsyncStateMachine> asyncStateMachineBox2)
280 {
281 if (asyncStateMachineBox2.StateMachine == null)
282 {
284 asyncStateMachineBox2.StateMachine = stateMachine;
285 }
286 asyncStateMachineBox2.Context = executionContext;
287 return asyncStateMachineBox2;
288 }
290 AsyncStateMachineBox<TStateMachine> asyncStateMachineBox3 = (AsyncStateMachineBox<TStateMachine>)(taskField = (AsyncMethodBuilderCore.TrackAsyncMethodCompletion ? CreateDebugFinalizableAsyncStateMachineBox<TStateMachine>() : new AsyncStateMachineBox<TStateMachine>()));
291 asyncStateMachineBox3.StateMachine = stateMachine;
292 asyncStateMachineBox3.Context = executionContext;
293 if (TplEventSource.Log.IsEnabled())
294 {
295 TplEventSource.Log.TraceOperationBegin(asyncStateMachineBox3.Id, "Async: " + stateMachine.GetType().Name, 0L);
296 }
298 {
299 System.Threading.Tasks.Task.AddToActiveTasks(asyncStateMachineBox3);
300 }
301 return asyncStateMachineBox3;
302 }
static void NotifyOfCrossThreadDependency()
Definition Debugger.cs:44
static ? ExecutionContext Capture()
static bool s_asyncDebuggingEnabled
Definition Task.cs:960
static bool AddToActiveTasks(Task task)
Definition Task.cs:1186
static readonly TplEventSource Log
static AsyncStateMachineBox< TStateMachine > CreateDebugFinalizableAsyncStateMachineBox< TStateMachine >()

References System.Threading.Tasks.Task< TResult >.AddToActiveTasks(), System.Threading.ExecutionContext.Capture(), System.Runtime.CompilerServices.AsyncTaskMethodBuilder< TResult >.CreateDebugFinalizableAsyncStateMachineBox< TStateMachine >(), System.Threading.Tasks.Task< TResult >.Id, System.L, System.Threading.Tasks.TplEventSource.Log, System.Diagnostics.Debugger.NotifyOfCrossThreadDependency(), System.Threading.Tasks.Task< TResult >.s_asyncDebuggingEnabled, System.stateMachine, and System.Runtime.CompilerServices.AsyncMethodBuilderCore.TrackAsyncMethodCompletion.