Consider a Console application that starts up some services in a separate thread. All it needs to do is wait for the user to press Ctrl+C to shut it down.
I already tried some examples, but all examples work with "do while".
Consider this code :
static void Main(string[] args)
{
for (long ContactId = 0; ContactId < 1000; ContactId++)
{
try
{
Task.WaitAll(CreateJson(ContactId));
}
catch (Exception ex)
{
System.IO.File.AppendAllText("error.txt", ContactId + "\n", encoding);
}
}
Console.WriteLine("Finalizado em " + watch.Elapsed + "");
Console.ReadKey();
}
How can I do some "listener" to stop the all the process and exit the console?
I already tried this example but not works fine for me (How to keep a .NET console app running?)
Thanks