Hide menu
Loading...
Searching...
No Matches

Provides progress status and notification mechanism. More...

Inheritance diagram for cadex.ProgressStatus:
cadex.BaseObject

Classes

class  CancellationChecker
 Base abstract class for cancelation checker registered in ProgressStatus. More...
 
class  Observer
 Base abstract class for observers registered in ProgressStatus. More...
 

Public Member Functions

 ProgressStatus (global::System.IntPtr cPtr, bool cMemoryOwn)
 
void Register (ProgressStatus.Observer theObserver, float theValueThreshold, uint theTimeThreshold)
 The life span of theObserver must be greater than one of this status object.
 
 ProgressStatus ()
 Returns true if the operation has been canceled.
 
double Value ()
 Beware of internal rounding errors.
 
void SetObserversNotifyingThread ()
 Sets the current thread as the only thread sending notifications for all registered observers.
 
void Cancel ()
 This callback is called when ProgressStatus.Cancel() was called.
 
bool WasCanceled ()
 The operation can be canceled either by explicit call to Cancel() or when a cancelation checker set with SetCancellationChecker() returned true.
 
void Register (ProgressStatus.Observer theObserver, float theValueThreshold)
 
void Register (ProgressStatus.Observer theObserver)
 
void Unregister (ProgressStatus.Observer theObserver)
 Removes a previously added observer.
 
void SetCancellationChecker (ProgressStatus.CancellationChecker theChecker)
 The life span of theChecker must be greater than of this object (because internally only a pointer to theChecker is stored).
 
void RemoveCancellationChecker ()
 Removes the cancellation checker.
 
- Public Member Functions inherited from cadex.BaseObject
 BaseObject (global::System.IntPtr cPtr, bool cMemoryOwn)
 
void Dispose ()
 
bool IsNull ()
 
ulong Id ()
 Return unique identifier of public object.
 
bool IsEqual (cadex.BaseObject theObj)
 
override int GetHashCode ()
 
override bool Equals (System.Object o)
 

Static Public Member Functions

static double MinValue ()
 
static double MaxValue ()
 

Protected Member Functions

override void Dispose (bool disposing)
 

Detailed Description

Provides progress status and notification mechanism.

ProgressStatus has a current Value() which belongs to the range [0, 100]. The algorithms that support progress status update increment this value during their execution.

Upon value change the status object notifies its observers (subclasses of the ProgressStatus.Observer class) registered with the Register() method. Thus, it implements the observer design pattern. The life span of the observer must be greater than the life span of the status object.

In the case there are no observers, the progress status incurs minimum overhead to the algorithm.

The status objects can be assigned to each other to create a chained range shared by several algorithms.

ProgressScope objects can be used to split progress status range into smaller scopes. The scopes can be nested.

For details refer to Progress Status Support section.

Examples
utilities/progress_bar/Program.cs, and utilities/progress_bar/main.cxx.

Constructor & Destructor Documentation

◆ ProgressStatus()

cadex.ProgressStatus.ProgressStatus ( )
inline

Returns true if the operation has been canceled.

The subclasses must redefine this operator to implement required behavior. Constructor.

Member Function Documentation

◆ Cancel()

void cadex.ProgressStatus.Cancel ( )
inline

This callback is called when ProgressStatus.Cancel() was called.

Default implementation is empty. A callback called when the progress status object was set to the canceled state.

◆ Dispose()

override void cadex.ProgressStatus.Dispose ( bool disposing)
inlineprotectedvirtual

Reimplemented from cadex.BaseObject.

◆ Register()

void cadex.ProgressStatus.Register ( ProgressStatus.Observer theObserver,
float theValueThreshold,
uint theTimeThreshold )
inline

The life span of theObserver must be greater than one of this status object.

If this cannot be guaranteed then the observer must be removed using the Unregister() method.

Registered observers will receive notification of a new value of this status object if the both following conditions are true:

  • the difference between a value used in previous notification is equal to or greater than theValueThreshold and
  • the time passed since previous notification is equal to or greater theTimeThreshold (specified in milliseconds).

Changing these thresholds you can manipulate frequency of the notifications for each observer.

See also
Unregister().
Examples
utilities/progress_bar/Program.cs, and utilities/progress_bar/main.cxx.

◆ RemoveCancellationChecker()

void cadex.ProgressStatus.RemoveCancellationChecker ( )
inline

Removes the cancellation checker.

◆ SetCancellationChecker()

void cadex.ProgressStatus.SetCancellationChecker ( ProgressStatus.CancellationChecker theChecker)
inline

The life span of theChecker must be greater than of this object (because internally only a pointer to theChecker is stored).

See also
RemoveCancellationChecker(). Sets the cancellation checker

◆ SetObserversNotifyingThread()

void cadex.ProgressStatus.SetObserversNotifyingThread ( )
inline

Sets the current thread as the only thread sending notifications for all registered observers.

◆ Unregister()

void cadex.ProgressStatus.Unregister ( ProgressStatus.Observer theObserver)
inline

Removes a previously added observer.

◆ Value()

double cadex.ProgressStatus.Value ( )
inline

Beware of internal rounding errors.

You might want to round the returned value to get a required precision for more confident usage. Returns a current value.

The values is in the range [0, 100].

Examples
utilities/progress_bar/Program.cs, and utilities/progress_bar/main.cxx.

◆ WasCanceled()

bool cadex.ProgressStatus.WasCanceled ( )
inline

The operation can be canceled either by explicit call to Cancel() or when a cancelation checker set with SetCancellationChecker() returned true.

See also
Cancel(). Returns true if the operation has been canceled.
Examples
utilities/progress_bar/Program.cs, and utilities/progress_bar/main.cxx.