Skip to content

Commit

Permalink
altered dotnet-counters to work with inputRedirection #2329 (#2466)
Browse files Browse the repository at this point in the history
* altered dotnet-counters to work with inputRedirection #2329

* Altered to allow for multiple key presses and removed debugging code

* Altered to allow for multiple key presses
  • Loading branch information
mikelle-rogers authored Sep 14, 2021
1 parent 1aba42f commit 49f7394
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Tools/dotnet-counters/CounterMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public async Task<int> Monitor(
{
return ReturnCode.ArgumentError;
}
_ct.Register(() => _shouldExit.TrySetResult(ReturnCode.Ok));
ct.Register(() => _shouldExit.TrySetResult(ReturnCode.Ok));

DiagnosticsClientBuilder builder = new DiagnosticsClientBuilder("dotnet-counters", 10);
using (DiagnosticsClientHolder holder = await builder.Build(ct, _processId, diagnosticPort, showChildIO: false, printLaunchCommand: false))
Expand Down Expand Up @@ -537,7 +537,7 @@ public async Task<int> Collect(
return ReturnCode.ArgumentError;
}

_ct.Register(() => _shouldExit.TrySetResult(ReturnCode.Ok));
ct.Register(() => _shouldExit.TrySetResult(ReturnCode.Ok));

DiagnosticsClientBuilder builder = new DiagnosticsClientBuilder("dotnet-counters", 10);
using (DiagnosticsClientHolder holder = await builder.Build(ct, _processId, diagnosticPort, showChildIO: false, printLaunchCommand: false))
Expand Down Expand Up @@ -841,7 +841,7 @@ private Task<int> Start()
while(!_shouldExit.Task.Wait(250))
{
HandleBufferedEvents();
if (Console.KeyAvailable)
if (!Console.IsInputRedirected && Console.KeyAvailable)
{
ConsoleKey cmd = Console.ReadKey(true).Key;
if (cmd == ConsoleKey.Q)
Expand All @@ -858,7 +858,6 @@ private Task<int> Start()
}
}
}

StopMonitor();
return _shouldExit.Task;
}
Expand Down

0 comments on commit 49f7394

Please sign in to comment.