Created
February 11, 2019 11:00
-
-
Save chrisnas/ae8fa6e01ddada2b1726fd49ee0d83fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void OnStart() | |
{ | |
string sessionName = $"GcLogEtwSession_{_pid.ToString()}_{Guid.NewGuid().ToString()}"; | |
Console.WriteLine($"Starting {sessionName}...\r\n"); | |
_userSession = new TraceEventSession(sessionName, TraceEventSessionOptions.Create); | |
Task.Run(() => | |
{ | |
// only want to receive GC event | |
ClrEventsManager manager = new ClrEventsManager(_userSession, _pid, EventFilter.GC); | |
manager.GarbageCollection += OnGarbageCollection; | |
// this is a blocking call until the session is disposed | |
manager.ProcessEvents(); | |
Console.WriteLine("End of CLR event processing"); | |
}); | |
// add a header to the .csv file | |
WriteLine(Header); | |
} | |
protected override void OnStop() | |
{ | |
// when the session is disposed, the call to ProcessEvents() returns | |
_userSession.Dispose(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment