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); }
protected virtual void OnWorkPerformed(object sender, WorkPerformedEventArgs e) { WorkPerformed?.Invoke(sender, e); }
private static void OnWorkerWorkPerformed(object sender, WorkPerformedEventArgs e) { Console.WriteLine($"Work of type '{e.WorkType}' performed for about {e.Hours} hours."); }