Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit b9c7399

Browse files
stephentoubdanmoseley
authored andcommitted
Enable ETW/EventSource logging of task IDs for boxed state machines (#27115) (#27217)
* Wrap MoveNext Action for TPL event tracing Wraps the MoveNext action of the AsyncStateMachineBox in a continuation wrapper when async causality tracing is on so that the TPL event source can find the task that is associated with a continuation. Does not wrap otherwise. * Clarifying comment * removing trailing whitespace * code review feedback. Makes AsyncMethodBuilderCore.TryFindContinuationTask check to whether the target of a continuation is itself a task, as a fall-back to checking to see if the continuation is a ContinuationWrapper * Got rid of unnecessary null checks
1 parent 617091a commit b9c7399

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/AsyncMethodBuilder.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,9 @@ internal static Action TryGetStateMachineForDebugger(Action action) // debugger
10991099
}
11001100

11011101
internal static Task? TryGetContinuationTask(Action continuation) =>
1102-
(continuation?.Target as ContinuationWrapper)?._innerTask;
1102+
(continuation.Target is ContinuationWrapper wrapper) ?
1103+
wrapper._innerTask : // A wrapped continuation, created by an awaiter
1104+
continuation.Target as Task; // The continuation targets a task directly, such as with AsyncStateMachineBox
11031105

11041106
/// <summary>
11051107
/// Logically we pass just an Action (delegate) to a task for its action to 'ContinueWith' when it completes.

0 commit comments

Comments
 (0)