Advertisement
stanevplamen

EventThrow

Oct 29th, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2. using System.Threading.Tasks;
  3. using System.Timers;
  4.  
  5. namespace ConsoleApplication1
  6. {
  7.     class Demo
  8.     {
  9.         static void Main()
  10.         {
  11.             Remind alarmSet = new Remind();
  12.             alarmSet.CheckReminder();
  13.             Console.ReadLine();
  14.         }
  15.     }
  16.  
  17.     public class Remind
  18.     {
  19.         private static int counterAlarms = 0;
  20.         private double interval = 3000; // milliseconds
  21.  
  22.         public void CheckReminder()
  23.         {
  24.             Timer checkForTime = new Timer(interval);
  25.             checkForTime.Elapsed += new ElapsedEventHandler(checkForTime_Elapsed);
  26.             checkForTime.Enabled = true;
  27.         }
  28.  
  29.         private void checkForTime_Elapsed(object sender, ElapsedEventArgs e)
  30.         {
  31.             Console.WriteLine(counterAlarms++);
  32.         }      
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement