-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
Labels
area-System.Diagnostics.TracingenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additions
Milestone
Description
Normally when ETW or EventPipe sessions end a disable command is sent to any EventSources that were being monitored to indicate that monitoring has stopped. EventListener also stops listening when it is disposed, but it doesn't provide any notification that it is doing so.
Repro:
using System.Diagnostics;
using System.Diagnostics.Tracing;
class Program
{
static void Main(string[] args)
{
MyEventSource source = new MyEventSource();
using (MyEventListener listener = new MyEventListener())
{
listener.EnableEvents(source, EventLevel.Informational);
Debug.Assert(source.Enabled);
// uncommenting this line will make the assert below pass, but it shouldn't be necessary
//listener.DisableEvents(source);
}
Debug.Assert(!source.Enabled); // once the listener is disposed we expect OnEventCommand to be called with a disable command
}
}
[EventSource(Name ="MyEventSource")]
public class MyEventSource : EventSource
{
public bool Enabled;
protected override void OnEventCommand(EventCommandEventArgs command)
{
if(command.Command == EventCommand.Enable)
{
Enabled = true;
}
else
{
Enabled = false;
}
}
}
public class MyEventListener : EventListener
{
}Metadata
Metadata
Assignees
Labels
area-System.Diagnostics.TracingenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additions