Skip to main content

Posts

Showing posts from April, 2019

Events and Delegates

Class with 2 events  public class Worker     {         // Created 2 events         public event EventHandler OnCompleted;         public event EventHandler<WorkerArgs> InBetween;         public void DoWork(int age, string address)         {             for (int i = 0; i < age - 1; i++)             {                 Thread.Sleep(1000);                  // Either this way                 //var del= InBetween as EventHandler<WorkerArgs>;                 //if (del != null) del(this,new WorkerArgs(i,address));                 // Or Directly             ...