Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- public delegate void Timer(int seconds);
- class LoopInInterval
- {
- static void Main()
- {
- Timer t = new Timer(SayHi);
- t(30);
- }
- public static void SayHi(int seconds)
- {
- Stopwatch watch = new Stopwatch();
- watch.Start();
- while (true)
- {
- if (watch.Elapsed.TotalSeconds % seconds == 0)
- {
- Console.WriteLine("Hi");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement