TControllableTask
TTask
that can be controlledInheritance
Level | Ancestor | Description |
---|---|---|
1 | TObject | Ultimate ancestor in a class hierarchy |
2 | TBaseObject | A base class for objects that can be used instead of TObject . |
3 | TReferenceCountedObject | Object that keeps track of the number of times it is referenced from other objects |
4 | TTaskNode | Abstract base class for a node in a hierarchy of tasks and task groups |
5 | TTask |
Represents an atomic operation that can be executed by calling Execute .
|
6 | TControllableTask |
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
Scope | Visibility | Type | Name | Description |
---|---|---|---|---|
Instance | private | TTaskController | FController |
Methods
Scope | Visibility | Result | Name | Description |
---|---|---|---|---|
Instance | public | Create() | ||
Instance | public | Destroy() | ||
Instance | public | TProgress | GetProgress() |