var
ThreadHandle,
ThreadId: TThreadID
procedure ThreadProc;
begin
// mach was, auch GUI könnte man hier updaten etc...
// thread wird beendet
ExitThread(0);
end;
procedure foobar;
begin
// einen thread wartend initialisieren
ThreadHandle := CreateThread(
nil, LongWord(0), @ThreadProc,
nil, CREATE_SUSPENDED, ThreadId);
// priorität festlegen
SetThreadPriority(ThreadHandle, THREAD_PRIORITY_ABOVE_NORMAL);
// thread starten
ResumeThread(ThreadHandle);
// einen thread abschießen
if ((ThreadHandle <> 0)
and (ThreadHandle <> INVALID_HANDLE_VALUE))
then
begin
TerminateThread(ThreadHandle, 0);
WaitForSingleObject(ThreadHandle, 50);
if ((ThreadHandle <> 0)
and (ThreadHandle <> INVALID_HANDLE_VALUE))
then
CloseHandle(ThreadHandle);
end;
end;