interface Tinman.Core.Threading.Operations.IOperation

Base interface that can be run via the RunningOperation class.

A class that implements the IOperation interface performs a lengthy task. Typically, this task will be executed in a background thread. Running background operations are represented by instances of the RunningOperation class.

A running background operation provides its current progress via an IProgressMonitor object that has been passed to its Run method.

When a background operation is executed, the following tasks are performed:

  1. The Run method is called and the operation performs the actual work, providing the its current progress using the given IProgressMonitor object.

  2. After the background operation has ended (finished, failed or cancelled), it is disposed (see IDisposable.Dispose). Cleanup should be performed there.

Public / Methods


public method Cancel → ()

Requests that the running background operation gracefully terminates.

An IOperation is free to honour a cancel request or to ignore it. Cancelling a background operation should be considered as a hint to terminate as soon as possible.


public method Run → (1)

progress in : IProgressMonitor

The progress monitor object to use.

Runs the operation.

If an exception resp. error occurs, it will be reported via IProgressMonitor.Error, and the Run method will return.

Public / Attributes


public attribute Name → (get)

value : string

The name.

Returns the human-readable name of this background operation.


public attribute ShallCancel → (get)

value : bool

true if the operation shall cancel, false if not.

Shall the background operation cancel?

Once Cancel has been called, this property will return true.


public attribute Weight → (get)

value : int32

The weight of this operation.

The weight of this operation.

This value is only used for reporting progress when combining multiple operations.



[OwnerReturn] [OwnerThis]
public static method RunBackground → ()

returns → RunningOperation

The RunningOperation object that represents the running background operation.

Runs the operation in a new background thread.


public static method RunSync → ()

Runs the operation synchronously in the calling thread.


If the operation has failed.


public static method RunTerminal → ()

returns → TinmanError

The error if the background operation has failed, null if it has finished successfully.

Runs the operation in a new background thread blocks the calling thread until it has finished, while displaying a simple progress indicator in the console.

This method is intended to be used for testing.