I am trying to run a .NET Core 1.0.0 console application inside a docker container.
When I run dotnet run
command from inside the Demo folder on my machin
I am not sure why Console.ReadLine();
doesn't block the main thread when running a .NET Core console app in a detached docker container, but the best solution is to register a ConsoleCancelEventHandler
with the Console.CancelKeyPress
event.
Then you can instead block the main thread with a type of Threading WaitHandle
and signal the release of the main thread when Console.CancelKeyPress
is fired.
A good example code can be found here: https://gist.github.com/kuznero/73acdadd8328383ea7d5