Add a CancelKeyPress event handler to properly stop trace.

Signed-off-by: Zac Brown <zac@zacbrown.io>
This commit is contained in:
Zac Brown
2017-01-06 10:37:10 -08:00
parent 1595325649
commit e0f70a7cda
+8
View File
@@ -31,6 +31,14 @@ namespace PowerShellMethodAuditor
trace.Enable(powershellProvider);
Console.CancelKeyPress += (sender, eventArg) =>
{
if (trace != null)
{
trace.Stop();
}
};
// This is a blocking call. Ctrl-C to stop.
trace.Start();
}