public void Process() { var count = 0; Task.Factory.StartNew(() => { logger.LogInformation("Process started!"); while (true) { consolePrinter.Print(++count); Thread.Sleep(1000); } }); Console.WriteLine("Press Ctrl + C to cancel!"); Console.CancelKeyPress += ((s, a) => { Console.WriteLine("Bye!"); _closingEvent.Set(); }); _closingEvent.WaitOne(); }
public void Print() { _printer.Print(this); }