Пример #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);
            //}
        }
Пример #2
0
 protected virtual void OnWorkPerformed(object sender, WorkPerformedEventArgs e)
 {
     WorkPerformed?.Invoke(sender, e);            // если не null,то вызовем invoke
 }
Пример #3
0
 private static void OnWorkerWorkPerformed(object sender, WorkPerformedEventArgs e)
 {
     Console.WriteLine($"1 Work of type' { e.WorkType}' performed for about { e.Hours} hours");
 }