Class TWinThread (unit WThread)

Inherits from

TCustomControl

Constructors


constructor Create(AComponent: TComponent);

will be resumed later


Functions

function CanClose: Boolean;

Spawn a new thread passing it Param as a parameter

destructor Destroy;

Mutex name

function KillThreads: Boolean;


procedure SafeExec(Param: LongInt);

destroy all threads

function SpawnThread(Param: pointer): THandle;

remove thread from our list

procedure Wait;

execute SafeExecCode in main process space using SendMessage

handles will be closed in WaitWinThread


procedure WaitExec(Param: LongInt);

execute SafeExecCode in main process space using PostMessage

Thread will not wait for main thread to process message


function WaitWithTimeOut(aTimeOut: DWord): DWord;

wait for all threads to terminate

function GetPriority(Index: Integer): LongInt;


procedure Loaded;

make sure that no wait threads are hanging around

procedure LockHandles;


procedure Paint;

Make sure no one is modifying the thread list

procedure ReleaseHandles;


procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer);


procedure SetPriority(Index: Integer; Value: LongInt);

Make sure no one is modifying the thread list

function GetCount: LongInt;

handles will be closed in WaitWinThread

function WaitWinThread(Sender: TComponent; aThreadInfo: TWinThreadParam): THandle;

Thread will wait for main thread to process message

procedure WMSafeExec(var aMsg: TMessage);

Make sure no one is modifying the thread list

procedure WMThreadException(var aMsg: TMessage);

Thread Terminate Event is executed in main process space

procedure WMThreadTerm(var aMsg: TMessage);


Properties

property Attributes : DWORD


property CallOnKill : Boolean


property SafeExecCode : TSafeExecCode

timeout is the max time for this component to wait for mutexes and events - default is infinite

property StackSize : LongInt

call ThreadTerminate code if thread is killed abnormally

property ThreadException : TWinThreadException

code that gets executed in main process space when SafeExec is call from within thread

property ThreadProc : TWinThreadEvent


property ThreadTerminate : TWinThreadEvent

code to execute in a separate thread when spawn is called

property TimeOut : LongInt

size of stack to give thread - 0 means same as exe's stack

property Count : LongInt

property Security: ^TSecurityAttributes read FSecurity write FSecurity default;

property Destroying : Boolean

return the number of active threads

property Killing : Boolean


property Priority : LongInt


Events

Variables

FAttributes : DWORD;

Private declarations

FCallOnKill : Boolean;


FDestroying : Boolean;


FKilling : Boolean;


FSafeExecCode : TSafeExecCode;


FSecurity : ^TSecurityAttributes;


FSpawnEvent : THandle;


FSpawnMutex : THandle;


FStackSize : LongInt;


FThreadException : TWinThreadException;


FThreadHandles : TList;


FThreadProc : TWinThreadEvent;


FThreadTerminateEvent : TWinThreadEvent;


FTimeOut : LongInt;


FWaitWinThreadHandles : TList;



Constructors


constructor Create(AComponent: TComponent);

will be resumed later


Functions


function CanClose: Boolean;

Spawn a new thread passing it Param as a parameter


destructor Destroy;

Mutex name


function KillThreads: Boolean;


procedure SafeExec(Param: LongInt);

destroy all threads


function SpawnThread(Param: pointer): THandle;

remove thread from our list


procedure Wait;

execute SafeExecCode in main process space using SendMessage

handles will be closed in WaitWinThread


procedure WaitExec(Param: LongInt);

execute SafeExecCode in main process space using PostMessage

Thread will not wait for main thread to process message


function WaitWithTimeOut(aTimeOut: DWord): DWord;

wait for all threads to terminate


function GetPriority(Index: Integer): LongInt;


procedure Loaded;

make sure that no wait threads are hanging around


procedure LockHandles;


procedure Paint;

Make sure no one is modifying the thread list


procedure ReleaseHandles;


procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer);


procedure SetPriority(Index: Integer; Value: LongInt);

Make sure no one is modifying the thread list


function GetCount: LongInt;

handles will be closed in WaitWinThread


function WaitWinThread(Sender: TComponent; aThreadInfo: TWinThreadParam): THandle;

Thread will wait for main thread to process message


procedure WMSafeExec(var aMsg: TMessage);

Make sure no one is modifying the thread list


procedure WMThreadException(var aMsg: TMessage);

Thread Terminate Event is executed in main process space


procedure WMThreadTerm(var aMsg: TMessage);


Properties


property Attributes : DWORD


property CallOnKill : Boolean


property SafeExecCode : TSafeExecCode

timeout is the max time for this component to wait for mutexes and events - default is infinite


property StackSize : LongInt

call ThreadTerminate code if thread is killed abnormally


property ThreadException : TWinThreadException

code that gets executed in main process space when SafeExec is call from within thread


property ThreadProc : TWinThreadEvent


property ThreadTerminate : TWinThreadEvent

code to execute in a separate thread when spawn is called


property TimeOut : LongInt

size of stack to give thread - 0 means same as exe's stack


property Count : LongInt

property Security: ^TSecurityAttributes read FSecurity write FSecurity default;


property Destroying : Boolean

return the number of active threads


property Killing : Boolean


property Priority : LongInt


Events


Variables


FAttributes : DWORD;

Private declarations


FCallOnKill : Boolean;


FDestroying : Boolean;


FKilling : Boolean;


FSafeExecCode : TSafeExecCode;


FSecurity : ^TSecurityAttributes;


FSpawnEvent : THandle;


FSpawnMutex : THandle;


FStackSize : LongInt;


FThreadException : TWinThreadException;


FThreadHandles : TList;


FThreadProc : TWinThreadEvent;


FThreadTerminateEvent : TWinThreadEvent;


FTimeOut : LongInt;


FWaitWinThreadHandles : TList;