diff --git a/csharp/ProgressMonitor/ProgressMonitor.csproj b/csharp/ProgressMonitor/ProgressMonitor.csproj index 74cd3fd..58503ae 100644 --- a/csharp/ProgressMonitor/ProgressMonitor.csproj +++ b/csharp/ProgressMonitor/ProgressMonitor.csproj @@ -46,6 +46,7 @@ + diff --git a/csharp/ProgressMonitor/devel/ComputeRelativeTimesProgressMonitor.cs b/csharp/ProgressMonitor/devel/ComputeRelativeTimesProgressMonitor.cs index 413f56f..acaf67b 100644 --- a/csharp/ProgressMonitor/devel/ComputeRelativeTimesProgressMonitor.cs +++ b/csharp/ProgressMonitor/devel/ComputeRelativeTimesProgressMonitor.cs @@ -20,7 +20,13 @@ public IDisposable ConfigureSteps(params int[] aSteps) { steps = new Step[aSteps.Length == 1 ? aSteps[0] : aSteps.Length]; - return next.ConfigureSteps(aSteps); + next.ConfigureSteps(aSteps); + + return new ActionDisposable(() => + { + if (currentStep >= 0 && currentStep < steps.Length) + Finished(); + }); } public void StartStep(string stepName = null) @@ -47,6 +53,8 @@ public void Finished() next.Finished(); DumpTimes(); + + currentStep++; } private void OnFinishedStep() diff --git a/csharp/ProgressMonitor/utils/ActionDisposable.cs b/csharp/ProgressMonitor/utils/ActionDisposable.cs new file mode 100644 index 0000000..1120ce2 --- /dev/null +++ b/csharp/ProgressMonitor/utils/ActionDisposable.cs @@ -0,0 +1,19 @@ +using System; + +namespace org.pescuma.progressmonitor.utils +{ + internal class ActionDisposable : IDisposable + { + private readonly Action dispose; + + public ActionDisposable(Action dispose) + { + this.dispose = dispose; + } + + public void Dispose() + { + dispose(); + } + } +} diff --git a/csharp/ProgressMonitor/utils/FlatToHierarchicalProgressMonitor.cs b/csharp/ProgressMonitor/utils/FlatToHierarchicalProgressMonitor.cs index 8576402..0d0e96a 100644 --- a/csharp/ProgressMonitor/utils/FlatToHierarchicalProgressMonitor.cs +++ b/csharp/ProgressMonitor/utils/FlatToHierarchicalProgressMonitor.cs @@ -228,20 +228,5 @@ public void ReportError(params string[] message) { flat.ReportError(message); } - - private class ActionDisposable : IDisposable - { - private readonly Action dispose; - - public ActionDisposable(Action dispose) - { - this.dispose = dispose; - } - - public void Dispose() - { - dispose(); - } - } } }