Beispiel #1
0
 protected virtual void OnTimeElapsed(TimeElapsedEventArgs eventArgs)
 {
     // Creating a temporary copy of the event
     TimeElapsedEventHandler newHandler = TimeElapsed;
     if (newHandler != null)
     {
         newHandler(this, eventArgs); // Handling the event
     }
 }
 static void TestMethod(object sender, TimeElapsedEventArgs eventArgs)
 {
     Console.WriteLine("I'm a method sent by a '{0}' object and called at {1}.",
         sender.GetType().Name, eventArgs.DateTimeNow.ToLongTimeString());
 }