EventSource callback behavior

For an EventCommand.Disable, the EventSource is now marked as disabled before the callback is issued.

Previous behavior

Previously, the EventSource.OnEventCommand(EventCommandEventArgs) callback was issued for an EventCommand.Disable prior to setting m_eventSourceEnabled=false.

This meant that EventSource.IsEnabled() returned true in the OnEventCommand(EventCommandEventArgs) callback for a user EventSource, even if the command led to the EventSource being disabled. The callback happened after the ability to dispatch events was turned off though, so even if an EventSource tried to fire an event, it wasn't written.

New behavior

Now, the EventSource is marked as disabled before the callback is issued for an EventCommand.Disable.

Version introduced

  • .NET 6 servicing
  • .NET 7 servicing

Type of breaking change

This change is a behavioral change.

Reason for change

This change was necessary to support multiple EventCounter instances. The ability to have multiple instances has been requested by multiple customers.

In addition, EventCommand.Enable has always issued a consistent view: EventSource.IsEnabled() accurately reports the enabled status, and EventSource can write events from the OnEventCommand callback. This change makes the EventCommand.Disable behavior consistent with EventCommand.Enable.

It's unlikely that there's a scenario where the previous behavior is desired, and there's no way to revert the behavior.

Affected APIs