Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- public class BohEventArgs : EventArgs
- {
- public DateTime oraCorrente { get; set; }
- public BohEventArgs(DateTime o) { oraCorrente = o; }
- public override string ToString()
- {
- return oraCorrente.Hour + ":" + oraCorrente.Minute;
- }
- }
- class Program
- {
- public static event Action<EventArgs> sonoDieci;
- static void Main(string[] args)
- {
- int conta = 0;
- sonoDieci += (ora) =>
- {
- Console.WriteLine("Sono passati 10 secondi, e sono le ore: " + ora.ToString());
- conta = 0;
- };
- System.Timers.Timer a = new System.Timers.Timer(1000);
- a.Start();
- a.Elapsed += (o, e) =>
- {
- if (sonoDieci != null && conta == 10) sonoDieci(new BohEventArgs(DateTime.Now));
- conta++;
- };
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement