Example #1
0
 public void Begin()
 {
     if (Interval == 0)
     {
         Console.WriteLine("This interval must be greater than 0.");
         return; //or break;
     }
     while (true)
     {
         System.Threading.Thread.Sleep(Interval);                                 //causes code to stop for 'interval' milliseconds.
         if (Tick != null)                                                        //delegate-Tick does have some targetMethod assigned to it.
         {
             TickerTimeEventArgs tickerTimeEventArgs = new TickerTimeEventArgs(); //default constructor creates obj of some event-type
             tickerTimeEventArgs.Time = DateTime.Now;
             Tick(this, tickerTimeEventArgs);                                     //params sent to .Tick delegate are forwarded to 'onTickCallThis' sender obj & eventClass obj containing time info.
         }
     }
 }
Example #2
0
 private void OnTickCallThis(Object sender, TickerTimeEventArgs e)
 {
     Console.WriteLine(string.Format("{0}: Ticker just ticked at time index {1}!", Id, e.Time));
 }