public static void Main(string[] args)
Progress p = new Progress();
public EventHandler ProgressStartedEvent;
public EventHandler<ProgressInfoEventArgs> UpdateProgressEvent;
public EventHandler ProgressCompletedEvent;
public void Start(int max, int interval = 1, int start = 0)
throw new ArgumentException("The interval parameter must not be less than or equal to 0");
throw new ArgumentException(string.Format("The start ({0}) parameter must not be greater than max parameter ({0})", start, max));
for (int i = start; i <= max; i += interval)
OnProgressUpdate(new ProgressInfoEventArgs(i, max));
protected virtual void OnProgressStarted()
EventHandler handler = ProgressStartedEvent;
handler(this, new EventArgs());
protected virtual void OnProgressUpdate(ProgressInfoEventArgs e)
EventHandler<ProgressInfoEventArgs> handler = UpdateProgressEvent;
protected virtual void OnProgressCompleted()
EventHandler handler = ProgressCompletedEvent;
handler(this, new EventArgs());
public class ProgressInfoEventArgs : EventArgs
public ProgressInfoEventArgs(double currentProgress, int max)
double dblMax = (double)max;
CurrentProgress = currentProgress / dblMax;
public double CurrentProgress { get; set; }