Description | Hierarchy | Fields | Methods | Properties |
type unaThread = class(unaObject)
unaThread
constructor create(active: bool = false; priority: int = THREAD_PRIORITY_NORMAL ); |
|
function getHandle(): tHandle; |
|
function getThreadId(): unsigned; |
|
function pause(): bool; |
|
function resume(): bool; |
|
class function shouldStopThread(globalID: unsigned): bool; |
|
function sleepThread(value: tTimeout): bool; |
|
function start(timeout: tTimeout = 10000): bool; |
|
function stop(timeout: tTimeout = tTimeout(INFINITE); force: bool = false): bool; |
|
function waitForExecute(timeout: tTimeout = 3000): bool; |
|
function waitForTerminate(timeout: tTimeout = 3000): bool; |
|
function execute(globalIndex: unsigned): int; virtual; |
|
function grantStart(): bool; virtual; |
|
function grantStop(): bool; virtual; |
|
function onPause(): bool; virtual; |
|
function onResume(): bool; virtual; |
|
procedure AfterConstruction(); override; |
|
procedure askStop(); |
|
procedure BeforeDestruction(); override; |
|
procedure wakeUp(); |
|
procedure setDefaultStopTimeout(value: tTimeout); |
|
procedure startIn(); virtual; |
|
procedure startOut(); virtual; |
property globalIndex: unsigned read f_globalThreadIndex; |
|
property onExecute: unaThreadOnExecuteMethod read f_onExecute write f_onExecute; |
|
property priority: int read getPriority write setPriority; |
|
property shouldStop: bool read getShouldStop; |
|
property status: unaThreadStatus read getStatus write doSetStatus; |
constructor create(active: bool = false; priority: int = THREAD_PRIORITY_NORMAL ); |
|
Creates new thread if active is true. If active is false thread will be created by calling the start() method.
Parameters
|
function getHandle(): tHandle; |
|
ReturnsThread handle. |
function getThreadId(): unsigned; |
|
ReturnsThread ID |
function pause(): bool; |
|
Suspends thread execution. |
function resume(): bool; |
|
Resumes thread execution. |
class function shouldStopThread(globalID: unsigned): bool; |
|
Returns true if thread with specified ID was marked to termination. |
function sleepThread(value: tTimeout): bool; |
|
Pauses the thread for specified amount of milliseconds. Pause may be interrupted by resume(), start(), wakeUp() and stop() mehtods. ReturnsTrue if pause was interruped, false otherwise. |
function start(timeout: tTimeout = 10000): bool; |
|
Starts the thread. |
function stop(timeout: tTimeout = tTimeout(INFINITE); force: bool = false): bool; |
|
Stops the thread. |
function waitForExecute(timeout: tTimeout = 3000): bool; |
|
Wait till thread enters execute method. |
function waitForTerminate(timeout: tTimeout = 3000): bool; |
|
Wait till thread is terminated. |
function execute(globalIndex: unsigned): int; virtual; |
|
This method will be called when execution starts in a new thread. Override this method in your own threads. Return value indicates result code of thread execution. You must check the shouldStop property periodically in your code. When shouldStop is set to true this function should return as soon as possible. |
function grantStart(): bool; virtual; |
|
Called just before execute() method. Should return true unless it is not desired to continue the execution of a thread. |
function grantStop(): bool; virtual; |
|
Called just before shouldStop property will be set to true. Should return true unless it is not desired to stop the thread execution. |
function onPause(): bool; virtual; |
|
function onResume(): bool; virtual; |
|
procedure AfterConstruction(); override; |
|
procedure askStop(); |
|
Notifies the thread it should be stopped ASAP. |
procedure BeforeDestruction(); override; |
|
Destroys the thread. If thread is running, stops it by calling the stop() method. |
procedure setDefaultStopTimeout(value: tTimeout); |
|
procedure startIn(); virtual; |
|
Called just before execute() method from thread's context. |
procedure startOut(); virtual; |
|
Called just after execute() method from thread's context. |
property globalIndex: unsigned read f_globalThreadIndex; |
|
Thread index in internal array. |
property onExecute: unaThreadOnExecuteMethod read f_onExecute write f_onExecute; |
|
Fires when execution starts in a new thread. See comments for execute() method for details. |
property priority: int read getPriority write setPriority; |
|
Specifies the priority of the thread. |
property shouldStop: bool read getShouldStop; |
|
True when thread should be stopped. |
property status: unaThreadStatus read getStatus write doSetStatus; |
|
Thread status |
(c) 2012 Lake of Soft