Skip to content

Commit 32cac1b

Browse files
author
Steve Salas
committed
Pressing Enter will stop web application trace
1 parent be054cc commit 32cac1b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

dotnet-tracer/main/CodePulse.Console/Program.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,18 @@ private static int RunIisWebApplication(CommandLineParser parser, Action<StringD
348348
LogMandatoryInfo($"Trace will stop when either '{WorldWideWebPublishingServiceDisplayName}' stops or Code Pulse ends the trace.");
349349

350350
var service = w3SvcService;
351+
Task.Run(() =>
352+
{
353+
System.Console.WriteLine();
354+
System.Console.WriteLine();
355+
System.Console.WriteLine("Press Enter to end web application and tracing...");
356+
System.Console.ReadLine();
357+
358+
Logger.Info("Stopping service...");
359+
service.StopService(TimeSpan.MaxValue);
360+
Logger.Info("Service stopped");
361+
});
362+
351363
Task.WaitAny(
352364
Task.Run(() => service.WaitForStatus(ServiceControllerStatus.Stopped)),
353365
Task.Run(() => _persistence.WaitForShutdown()));

0 commit comments

Comments
 (0)