public ProgressMonitor BeginAsyncStep(string message, int work) { if (currentTask == null) { throw new InvalidOperationException("Task not started in progress monitor"); } if (work < 0) { throw new ArgumentException("work can't be negative"); } ConsumePendingWork(); if (message != null) { currentTask.Step(message, 0); } ProgressMonitor m = null; if (context != null) { context.Send((o) => m = CreateAsyncStepMonitor(), null); } else { m = CreateAsyncStepMonitor(); } m.SetParentTask(this, currentTask, work); if (context != null) { context.Post((o) => { OnBeginAsyncStep(message, work, m); ReportProgressChanged(); }, null); } else { OnBeginAsyncStep(message, work, m); ReportProgressChanged(); } if (slaveMonitors != null) { foreach (var sm in slaveMonitors) { m.AddSlaveMonitor(sm.BeginAsyncStep(message, work)); } } return(m); }