private static void ByTimerCancelation() { var interval = 3000; var infiniteAction = new InfiniteAction(Rogue.RogueFunction); Console.WriteLine($"RogueFunction is executing and will be stopped in {interval} ms."); Console.WriteLine("Make sure it has stopped and press any key to exit."); infiniteAction.Start(); var timer = new Timer(StopInfiniteAction, infiniteAction, interval, -1); Console.ReadKey(); Console.WriteLine(); }
private static void ManualCancelation() { var infiniteAction = new InfiniteAction(Rogue.RogueFunction); Console.WriteLine("RogueFunction is executing."); infiniteAction.Start(); Console.WriteLine("Press any key to stop it."); Console.ReadKey(); Console.WriteLine(); infiniteAction.Stop(); Console.WriteLine("Make sure it has stopped and press any key to exit."); Console.ReadKey(); Console.WriteLine(); }