Skip to content

Commit 49f7394

Browse files
altered dotnet-counters to work with inputRedirection #2329 (#2466)
* 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
1 parent 1aba42f commit 49f7394

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Tools/dotnet-counters/CounterMonitor.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ public async Task<int> Monitor(
464464
{
465465
return ReturnCode.ArgumentError;
466466
}
467-
_ct.Register(() => _shouldExit.TrySetResult(ReturnCode.Ok));
467+
ct.Register(() => _shouldExit.TrySetResult(ReturnCode.Ok));
468468

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

540-
_ct.Register(() => _shouldExit.TrySetResult(ReturnCode.Ok));
540+
ct.Register(() => _shouldExit.TrySetResult(ReturnCode.Ok));
541541

542542
DiagnosticsClientBuilder builder = new DiagnosticsClientBuilder("dotnet-counters", 10);
543543
using (DiagnosticsClientHolder holder = await builder.Build(ct, _processId, diagnosticPort, showChildIO: false, printLaunchCommand: false))
@@ -841,7 +841,7 @@ private Task<int> Start()
841841
while(!_shouldExit.Task.Wait(250))
842842
{
843843
HandleBufferedEvents();
844-
if (Console.KeyAvailable)
844+
if (!Console.IsInputRedirected && Console.KeyAvailable)
845845
{
846846
ConsoleKey cmd = Console.ReadKey(true).Key;
847847
if (cmd == ConsoleKey.Q)
@@ -858,7 +858,6 @@ private Task<int> Start()
858858
}
859859
}
860860
}
861-
862861
StopMonitor();
863862
return _shouldExit.Task;
864863
}

0 commit comments

Comments
 (0)