@@ -3585,7 +3585,12 @@ internal void FinishContinuations()
3585
3585
// Atomically store the fact that this task is completing. From this point on, the adding of continuations will
3586
3586
// result in the continuations being run/launched directly rather than being added to the continuation list.
3587
3587
object continuationObject = Interlocked . Exchange ( ref m_continuationObject , s_taskCompletionSentinel ) ;
3588
- TplEtwProvider . Log . RunningContinuation ( Id , continuationObject ) ;
3588
+ TplEtwProvider etw = TplEtwProvider . Log ;
3589
+ bool tplEtwProviderLoggingEnabled = etw . IsEnabled ( ) ;
3590
+ if ( tplEtwProviderLoggingEnabled )
3591
+ {
3592
+ etw . RunningContinuation ( Id , continuationObject ) ;
3593
+ }
3589
3594
3590
3595
// If continuationObject == null, then we don't have any continuations to process
3591
3596
if ( continuationObject != null )
@@ -3658,7 +3663,10 @@ internal void FinishContinuations()
3658
3663
var tc = continuations [ i ] as StandardTaskContinuation ;
3659
3664
if ( tc != null && ( tc . m_options & TaskContinuationOptions . ExecuteSynchronously ) == 0 )
3660
3665
{
3661
- TplEtwProvider . Log . RunningContinuationList ( Id , i , tc ) ;
3666
+ if ( tplEtwProviderLoggingEnabled )
3667
+ {
3668
+ etw . RunningContinuationList ( Id , i , tc ) ;
3669
+ }
3662
3670
continuations [ i ] = null ; // so that we can skip this later
3663
3671
tc . Run ( this , bCanInlineContinuations ) ;
3664
3672
}
@@ -3672,7 +3680,10 @@ internal void FinishContinuations()
3672
3680
object currentContinuation = continuations [ i ] ;
3673
3681
if ( currentContinuation == null ) continue ;
3674
3682
continuations [ i ] = null ; // to enable free'ing up memory earlier
3675
- TplEtwProvider . Log . RunningContinuationList ( Id , i , currentContinuation ) ;
3683
+ if ( tplEtwProviderLoggingEnabled )
3684
+ {
3685
+ etw . RunningContinuationList ( Id , i , currentContinuation ) ;
3686
+ }
3676
3687
3677
3688
// If the continuation is an Action delegate, it came from an await continuation,
3678
3689
// and we should use AwaitTaskContinuation to run it.
0 commit comments