function TClientAdapter.ExpBeginThread(ThreadFunc: TThreadFunc; Parameter: Pointer; Timout : integer): boolean;
var
id : LongWord;
thread : Integer;
wf : DWORD;
begin
Result := false;
if fTimeout
then
begin
Result := false;
exit;
end
else
begin
thread := BeginThread(
nil, 0, ThreadFunc, Parameter, 0, id);
if (thread <> INVALID_HANDLE_VALUE)
then
begin
wf := WaitForSingleObject(thread, Timout);
case wf
of
WAIT_OBJECT_0:
begin
result := True;
end;
WAIT_TIMEOUT :
begin
TerminateThread(thread, 0);
Timeout := True;
result := False;
end;
WAIT_FAILED :
begin
Timeout := True;
result := False;
end;
end;
CloseHandle(thread);
end;
end;
end;
function TClientAdapter.LibKeepAlive(Sender: TObject): ByteBool;
var
data : LibKeepAliveData;
function ThreadLibKeepAlive(Parameter : Pointer) : integer;
begin
result := 0;
LibKeepAliveData(Parameter^).result := KeepAlive();
// DLL Call...
end;
begin
if ExpBeginThread(Addr(ThreadLibKeepAlive), Addr(data), gTimeout)
then
result := data.result
else
result := false;
end;