static void Main(string[] args) { Action<int> countMillisecs = (ms) => { Console.WriteLine($"{ms}ms passed..."); }; AsyncTimer timer = new AsyncTimer(countMillisecs, 5, 1000); timer.Start(); }
static void Main(string[] args) { Console.WriteLine("Enter the number of times for the repeated action:"); int ticks = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the interval between repetitions(in milliseconds):"); double interval = double.Parse(Console.ReadLine()); Console.WriteLine("Press the 'Esc' key if you want to stop the program!"); Action act = TimerMethod; AsyncTimer timer = new AsyncTimer(act, ticks, interval); timer.Run(); int i = 1; while (true) { if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape) { break; } Console.WriteLine("I'm an unstopable Main method {0}", i++); } }
static void Main() { AsyncTimer timer = new AsyncTimer(MessageToShow, 10, 500); Thread newThread = new Thread(RunAsync(timer)); newThread.Start(); Console.ReadLine(); }
public static void Main(string[] args) { var firstTimer = new AsyncTimer(Test1, 5, 500); var secondTimer = new AsyncTimer(Test2, 5, 1000); firstTimer.Run(); secondTimer.Run(); }
static void Main(string[] args) { Action <int> countMillisecs = (ms) => { Console.WriteLine($"{ms}ms passed..."); }; AsyncTimer timer = new AsyncTimer(countMillisecs, 5, 1000); timer.Start(); }
static void Main(string[] args) { AsyncTimer timer1 = new AsyncTimer(SayHello, 10, 1000); timer1.Start(); AsyncTimer timer2 = new AsyncTimer(PointlessMethod, 5, 2000); timer2.Start(); }
public static void Main() { Action f = testMethod;; AsyncTimer test = new AsyncTimer(f, 10, 500); test.Run(); string testString = Console.ReadLine(); }
static void Main() { AsyncTimer randomNumberPerSecond = new AsyncTimer(RandomNumber, 10, 1000); AsyncTimer newLine = new AsyncTimer(AddNewLine, 1, 11000); randomNumberPerSecond.Run(); newLine.Run(); }
static void Main(string[] args) { AsyncTimer first = new AsyncTimer(1000, 10, FirstStram); first.Start(); AsyncTimer second = new AsyncTimer(750, 15, SecondStream); second.Start(); AsyncTimer third = new AsyncTimer(550, 20, ThirdStream); third.Start(); }
static void Main(string[] args) { AsyncTimer print = new AsyncTimer(Print, 10, 1000); print.Start(); AsyncTimer beep = new AsyncTimer(BeeP, 10, 500); beep.Start(); }
public static void Main() { Action f = testMethod; ; AsyncTimer test = new AsyncTimer(f, 10, 500); test.Run(); string testString = Console.ReadLine(); }
static void Main(string[] args) { var timer = new AsyncTimer(() => Console.WriteLine("Halo"), 10, 1000); timer.Start(); while (!timer.IsReady) { } }
public static void Main(string[] args) { AsyncTimer first = new AsyncTimer(SaySomething, 10, 1000); first.StartTimer(); AsyncTimer second = new AsyncTimer(SaySomethingAgain, 10, 1000); second.StartTimer(); Console.WriteLine("work"); }
static void Main() { AsyncTimer timer1 = new AsyncTimer(method1, 500, 10); timer1.Start(); AsyncTimer timer2 = new AsyncTimer(method2, 1000, 10); timer2.Start(); }
static void Main(string[] args) { AsyncTimer timer1 = new AsyncTimer(Work1, 1000, 10); timer1.Start(); AsyncTimer timer2 = new AsyncTimer(Work2, 900, 10); timer2.Start(); }
public static void Main() { AsyncTimer runningTimer = new AsyncTimer(Announce, 10, 1000); runningTimer.Start(); Thread.Sleep(2020); Console.WriteLine("This is main program execution (delayed 2 sec.) not interupted by timer"); Thread.Sleep(2500); Console.WriteLine("This is again main program execution not interupted by timer"); Console.ReadKey(); }
static void Main() { Action cw = new Action(AddNewLine); Action cw2 = new Action(AddNewLine2); AsyncTimer timer = new AsyncTimer(cw, 10, 100); timer.ExecuteAction(); AsyncTimer timer2 = new AsyncTimer(cw2, 10, 100); timer2.ExecuteAction(); }
public static void Main(string[] args) { AsyncTimer at = new AsyncTimer(RespondMethod, 1000, 20); AsyncTimer at2 = new AsyncTimer(SecondMethod, 1000, 20); for (int i = 0; i < 100; i++) { Console.WriteLine("Main program action!"); Thread.Sleep(100); } }
public static void Main(string[] args) { AsyncTimer at = new AsyncTimer(RespondMethod, 200, 10); AsyncTimer at2 = new AsyncTimer(SecondMethod, 250, 30); for (int i = 0; i < 100; i++) { Console.WriteLine("Main program action!"); Thread.Sleep(100); } }
static void Main() { Action<string> action = Print; int ticks = 50; int t = 1000; AsyncTimer AsyncTimerObj = new AsyncTimer(action, ticks, t); AsyncTimerObj.Run("hello!!!"); }
public static void Main() { Console.WriteLine("Write because time is running out\n"); _firstTimer = new AsyncTimer(Method, 10, 1000); var input = ""; while (_firstTimer.Ticks != 0) { input = Console.ReadLine(); Console.WriteLine(input); } }
static void Main() { AsyncTimer asyncTimer = new AsyncTimer(PrintTime, 10, 2000); Task startTimer = asyncTimer.StartTimer(); Console.WriteLine("The task is completing, spam here: "); while (startTimer.IsCompleted == false) { Console.ReadLine(); } Console.WriteLine("The task has been completed!"); }
public static ThreadStart RunAsync(AsyncTimer timer) { ThreadStart newThread = () => { while (timer.Ticks > 0) { Stopwatch sb = new Stopwatch(); sb.Start(); while (sb.ElapsedMilliseconds <= timer.TimeInterval) { } Console.Write(timer); sb.Reset(); timer.Ticks--; } }; return newThread; }
public static void Main() { AsyncTimer timer = new AsyncTimer(Action, 10, 1000); timer.Start(); }
static void Main(string[] args) { AsyncTimer timerOne = new AsyncTimer(firstFunc, 10, 5); }
static void Main() { AsyncTimer at = new AsyncTimer(PassStringOne, 10, 1000); at.Begin(); }