| Class TWinThread (unit WThread) |
TCustomControl
| Constructors |
constructor Create(AComponent: TComponent);| Functions |
function CanClose: Boolean;
destructor Destroy;
function KillThreads: Boolean;
procedure SafeExec(Param: LongInt);
function SpawnThread(Param: pointer): THandle;
procedure Wait;handles will be closed in WaitWinThread
procedure WaitExec(Param: LongInt);Thread will not wait for main thread to process message
function WaitWithTimeOut(aTimeOut: DWord): DWord;
function GetPriority(Index: Integer): LongInt;
procedure Loaded;
procedure LockHandles;
procedure Paint;
procedure ReleaseHandles;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
procedure SetPriority(Index: Integer; Value: LongInt);
function GetCount: LongInt;
function WaitWinThread(Sender: TComponent; aThreadInfo: TWinThreadParam): THandle;
procedure WMSafeExec(var aMsg: TMessage);
procedure WMThreadException(var aMsg: TMessage);
procedure WMThreadTerm(var aMsg: TMessage);| Properties |
property Attributes : DWORD
property CallOnKill : Boolean
property SafeExecCode : TSafeExecCode
property StackSize : LongInt
property ThreadException : TWinThreadException
property ThreadProc : TWinThreadEvent
property ThreadTerminate : TWinThreadEvent
property TimeOut : LongInt
property Count : LongInt
property Destroying : Boolean
property Killing : Boolean
property Priority : LongInt| Events |
| Variables |
FAttributes : DWORD;
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 : TSafeExecCodetimeout is the max time for this component to wait for mutexes and events - default is infinite
property StackSize : LongIntcall ThreadTerminate code if thread is killed abnormally
property ThreadException : TWinThreadExceptioncode that gets executed in main process space when SafeExec is call from within thread
property ThreadProc : TWinThreadEvent
property ThreadTerminate : TWinThreadEventcode to execute in a separate thread when spawn is called
property TimeOut : LongIntsize of stack to give thread - 0 means same as exe's stack
property Count : LongIntproperty Security: ^TSecurityAttributes read FSecurity write FSecurity default;
property Destroying : Booleanreturn 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;