static void Main(string[] args) { Publisher p = new Publisher(); Subscriber s = new Subscriber(p);//mi sottoscrivo ad evento int count = 0; for (int i = 0; i < 30; i++) { if (i - count == 0) { p._numerogiri = i; p.OnMotoreSpento(); Thread.Sleep(2000); count += 10; } } Publisher1 p1 = new Publisher1(); Subscriber1 s1 = new Subscriber1(p1);//mi sottoscrivo ad evento int count1 = 0; for (int i = 0; i < 30; i++) { if (i - count1 == 0) { p1._numerogiri = i; p1.OnMotoreSpento(); Thread.Sleep(2000); count1 += 10; } } }
public Subscriber1(Publisher1 pub) { Console.WriteLine("mi sottoscrivo ad evento"); pub.MotoreSpento += Handle; }
private void Handle(object sender, EventArgs e) { Publisher1 c = sender as Publisher1; Console.WriteLine("OnMotoreSpento "); }