mirror of
https://github.com/zacbrown/PowerShellMethodAuditor
synced 2026-06-08 18:34:02 +00:00
Add a CancelKeyPress event handler to properly stop trace.
Signed-off-by: Zac Brown <zac@zacbrown.io>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user