Exemple #1
0
        public void DoSomeWork(int hours)
        {
            //before calling events make sure the delegate list isn't empty

            for (int i = 0; i < hours; i++)
            {
                //raise workevent
                WorkEvent?.Invoke(this, new CoolEventArgs()
                {
                    IsCool = true,
                    Number = i + 1
                });
            }

            var args = new CoolEventArgs()
            {
                IsCool = true,
                Number = hours
            };

            //raise workdone
            WorkDone?.Invoke(this, args);
        }
Exemple #2
0
 public static int WorkPerformed3(object sender, CoolEventArgs e)
 {
     Console.WriteLine($"Work Performed 3: {e.Number}");
     return(e.Number + 3);
 }