dotnet-monitor: Use CommandHandler CancellationToken for SIGINT detection (#365)
authorTom Deseyn <tom.deseyn@gmail.com>
Thu, 27 Jun 2019 17:07:50 +0000 (19:07 +0200)
committerSung Yoon Whang <suwhang@microsoft.com>
Thu, 27 Jun 2019 17:07:50 +0000 (10:07 -0700)
src/Tools/dotnet-counters/CounterMonitor.cs

index 399fe15d72335d1ed2fecff78d1637909052b955..07003ef85345385c4af5d15c97a86be9a38deea2 100644 (file)
@@ -166,6 +166,8 @@ namespace Microsoft.Diagnostics.Tools.Counters
             }
 
             ManualResetEvent shouldExit = new ManualResetEvent(false);
+            _ct.Register(() => shouldExit.Set());
+
             var terminated = false;
             writer.InitializeDisplay();
 
@@ -194,10 +196,7 @@ namespace Microsoft.Diagnostics.Tools.Counters
             });
 
             monitorTask.Start();
-            Console.CancelKeyPress += (sender, args) => {
-                args.Cancel = true;
-                shouldExit.Set();
-            };
+
             while(!shouldExit.WaitOne(250))
             {
                 while (true)