Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function StartThread(pFunction: TFNThreadStartRoutine;
- iPriority: Integer = Thread_Priority_Normal; iStartFlag: Integer = 0)
- : THandle;
- var
- ThreadID: DWORD;
- begin
- Result := CreateThread(nil, 0, pFunction, nil, iStartFlag, ThreadID);
- if Result <> Null then
- SetThreadPriority(Result, iPriority);
- end;
- Function CloseThread(ThreadHandle: THandle): Boolean;
- begin
- Result := TerminateThread(ThreadHandle, 1);
- CloseHandle(ThreadHandle);
- end;
- procedure Test;
- begin
- Delay(1000);
- FormMain.Edit1.Text := FormMain.Edit1.Text + 'ok ';
- //ShowMessage('kk');
- end;
- procedure TFormMain.Button14Click(Sender: TObject);
- var
- h: Cardinal;
- hThread: THandle;
- begin
- hThread := StartThread(@Test);
- FormMain.Edit2.Text := FormMain.Edit2.Text + 'ok ';
- CloseThread(hThread);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement