TControllableTask

A TTask that can be controlled

Inheritance

LevelAncestorDescription
1TObjectUltimate ancestor in a class hierarchy
2TBaseObjectA base class for objects that can be used instead of TObject.
3TReferenceCountedObjectObject that keeps track of the number of times it is referenced from other objects
4TTaskNodeAbstract base class for a node in a hierarchy of tasks and task groups
5TTask Represents an atomic operation that can be executed by calling Execute.
6TControllableTask

Source

Task.Controllable.pas (52)

Description

Use the Controller within the main loop of your task by using the following pattern:

1 2 3 4 5 6 7 Controller.SetTotal(StepsNeededToFinish); // This call may also be located in the constructor while not Controller.AtEnd do begin // Perform some steps Advance(StepsPerformedInThisIteration); end;

The call to Controller.SetTotal may actually be placed somewhere else, for instance, in the constructor of your task. Be sure that the task does not spend too much time in each iteration of the main loop as this would make your task unresponsive. Every time the loop condition is checked progress will be reported back to the user.

Also, be prepared for Controller.AtEnd to return True prematurely, before all steps have been executed. This means that the user has stopped the task from the user interface and you must clean upany resources the task might be holding or rollback changes. Moreover, Controller.AtEnd is not required to return immediately but is allowed to stall indefinitely. This might happen when the user pauses the task from the user interface. Be prepared that your task may encounter long pauses.

Fields

ScopeVisibilityTypeNameDescription
InstanceprivateTTaskControllerFController

Methods

ScopeVisibilityResultNameDescription
InstancepublicCreate()
InstancepublicDestroy()
InstancepublicTProgressGetProgress()