Beispiel #1
0
        public virtual void DoWork(int hours, WorkType workType)
        {
            for (int i = 0; i < hours; i++)
            {
                for (int j = 0; j < 100000; j++)
                {
                    ;
                }
                var e = new WorkPerformedEventArgs
                {
                    Hours    = i + 1,
                    WorkType = workType
                };

                OnWorkPerformed(this, e);
            }

            OnWorkComplete(this, EventArgs.Empty);

            //if (WorkComplete != null)
            //{
            //	WorkComplete(this , EventArgs.Empty);
            //}
        }
Beispiel #2
0
 protected virtual void OnWorkPerformed(object sender, WorkPerformedEventArgs e)
 {
     WorkPerformed?.Invoke(sender, e);            // если не null,то вызовем invoke
 }
Beispiel #3
0
 private static void OnWorkerWorkPerformed(object sender, WorkPerformedEventArgs e)
 {
     Console.WriteLine($"1 Work of type' { e.WorkType}' performed for about { e.Hours} hours");
 }