C# Class HFMCmd.ProgressMonitor

Utility class that can be used to monitor the progress of long-running operations via a separate thread. Supports both synchronous and asyncrhonous modes of operation (i.e. where the long-running operation is blocking or non-blocking).
ファイルを表示 Open project: agardiner/hfmcmd

Public Properties

Property Type Description
PollingInterval int

Protected Properties

Property Type Description
SLEEP_INTERVAL int
_log log4net.ILog
_monitorThread Thread
_output IOutput

Public Methods

Method Description
AsyncComplete ( ) : void

When an async operation is complete, this method should be called so that the main thread waits for the monitor thread to end and clean up the progress display.

MonitorProgress ( GetProgress progressFn ) : void

Monitors progress of an operation executing asynchronously in another thread. The supplied callback is used to determine the completion progress of the operation, and whether or not it is still running. This method blocks until the callback sets the isRunning parameter to false, or the IOutput instance indicates the operation should be cancelled, e.g. because the user hits the Escape key. For a non-blocking alternative, use MonitorProgressAsync.

MonitorProgressAsync ( GetProgress progressFn ) : void

Monitors progress of a synchronously executing (i.e. blocking) operation. This method spins up a background thread to poll the operation status, and so it returns immediately. Use this method when you want to monitor the progress of a long-running, blocking operation. Be sure to call this method immediately prior to invoking the operation.

ProgressMonitor ( IOutput output ) : System

Constructs a progress monitor for tracking the progress of a long- running operation and updating the progress status via an IOutput instance. Progress will be measured in percentage terms.

Method Details

AsyncComplete() public method

When an async operation is complete, this method should be called so that the main thread waits for the monitor thread to end and clean up the progress display.
public AsyncComplete ( ) : void
return void

MonitorProgress() public method

Monitors progress of an operation executing asynchronously in another thread. The supplied callback is used to determine the completion progress of the operation, and whether or not it is still running. This method blocks until the callback sets the isRunning parameter to false, or the IOutput instance indicates the operation should be cancelled, e.g. because the user hits the Escape key. For a non-blocking alternative, use MonitorProgressAsync.
public MonitorProgress ( GetProgress progressFn ) : void
progressFn GetProgress
return void

MonitorProgressAsync() public method

Monitors progress of a synchronously executing (i.e. blocking) operation. This method spins up a background thread to poll the operation status, and so it returns immediately. Use this method when you want to monitor the progress of a long-running, blocking operation. Be sure to call this method immediately prior to invoking the operation.
public MonitorProgressAsync ( GetProgress progressFn ) : void
progressFn GetProgress
return void

ProgressMonitor() public method

Constructs a progress monitor for tracking the progress of a long- running operation and updating the progress status via an IOutput instance. Progress will be measured in percentage terms.
public ProgressMonitor ( IOutput output ) : System
output IOutput
return System

Property Details

PollingInterval public_oe property

public int PollingInterval
return int

SLEEP_INTERVAL protected_oe static_oe property

protected static int SLEEP_INTERVAL
return int

_log protected_oe static_oe property

protected static ILog,log4net _log
return log4net.ILog

_monitorThread protected_oe property

protected Thread _monitorThread
return Thread

_output protected_oe property

protected IOutput _output
return IOutput