using System; using System.Threading; class A { public int n = 0; } public class TickTack { public static void Main() { String line; Console.WriteLine("Press Enter to terminate..."); TimerCallback callback = new TimerCallback(PrintTick); Timer t = new Timer(callback, new A(), 1000, 1000); line = Console.ReadLine(); } static void PrintTick(Object state) { int tick = ((A) state).n; ((A) state).n = 1 - tick; if (tick == 0) Console.WriteLine("tick"); else Console.WriteLine("tack"); } }