Skip to content

Commit

Permalink
Code Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
davmason committed May 9, 2023
1 parent 07d5819 commit 118a635
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private void OnEventSourceCommand(object? sender, EventCommandEventArgs e)

lock (s_counterGroupLock) // Lock the CounterGroup
{
if (e.Command == EventCommand.Enable)
if (e.Command == EventCommand.Enable || e.Command == EventCommand.Update)
{
Debug.Assert(e.Arguments != null);

Expand All @@ -62,18 +62,9 @@ private void OnEventSourceCommand(object? sender, EventCommandEventArgs e)
return;
}

// Sending an Enabled with EventCounterIntervalSec <=0 is a signal that we should immediately turn
// off counters
if (intervalValue <= 0)
{
DisableTimer();
}
else
{
EnableTimer(intervalValue);
}
EnableTimer(intervalValue);
}
else
else if (e.Command == EventCommand.Disable)
{
Debug.Assert(e.Command == EventCommand.Disable);
// Since we allow sessions to send multiple Enable commands to update the interval, we cannot
Expand Down Expand Up @@ -152,7 +143,11 @@ private void EnableTimer(float pollingIntervalInSeconds)
{
Debug.Assert(pollingIntervalInSeconds > 0);
Debug.Assert(Monitor.IsEntered(s_counterGroupLock));
if (_pollingIntervalInMilliseconds == 0 || pollingIntervalInSeconds * 1000 < _pollingIntervalInMilliseconds)
if (pollingIntervalInSeconds <= 0)
{
DisableTimer();
}
else if (_pollingIntervalInMilliseconds == 0 || pollingIntervalInSeconds * 1000 < _pollingIntervalInMilliseconds)
{
_pollingIntervalInMilliseconds = (int)(pollingIntervalInSeconds * 1000);
ResetCounters(); // Reset statistics for counters before we start the thread.
Expand Down

0 comments on commit 118a635

Please sign in to comment.