Assembly: Gallio (in Gallio.dll) Version: 3.3.0.0 (3.3.610.0)
Syntax
| C# |
|---|
public interface IProgressMonitor : IDisposable |
| Visual Basic (Declaration) |
|---|
Public Interface IProgressMonitor _ Implements IDisposable |
Remarks
The interface is typically implemented by a UI component such as a progress dialog.
This interface is inspired from IProgressMonitor in the Eclipse API and was derived from the Castle.FlexBridge client-side components.
This interface is mostly not safe for use by multiple concurrent threads. Do not share a progress monitor instance across threads! for special rules regarding the handling of the cancelation event.
The BeginTask(String, Double) method returns a ProgressMonitorTaskCookie which implements IDisposable as a convenience for use with the C# "using" statement. Disposing the cookie is precisely equivalent to calling the Done()()() method of the progress monitor.
Examples
// Copy a number of files to another directory, updating the progress // monitor before each file is copied to provide status feedback and // then after each file is copied to provide progress feedback. const int CostOfCopyingFile = 1; const int CostOfRunningExpensiveTask = 10; IProgressMonitor progressMonitor = progressMonitorDialog.GetProgressMonitor()) using (progressMonitor.BeginTask("Copy files", files.Length * CostOfCopyingFile + CostOfRunningExpensiveTask)) { foreach (FileInfo file in files) { if (progressMonitor.IsCancelled) return; progressMonitor.SetStatus("Copying: " + file.Name); File.Copy(file.FullName, Path.Combine(destinationFolder, file.Name)) progressMonitor.Worked(CostOfCopyingFile); } progressMonitor.SetStatus(""); DoExpensiveTask(progressMonitor.CreateSubProgressMonitor(CostOfRunningExpensiveTask)); }
