Ich hoffe es wird nicht peinlich.

im Main
Delphi-Quellcode:
if UncPath <> '' then
begin
tmpPath:= ExtractFileName(ExtractFiledir(ExtractFiledir(ExcludeTrailingPathDelimiter(UncPath))));
if tmpPath <> '' then
begin
PingThread:= TPingThread.Create(tmpPath);
PingHndl:= PingThread.Handle;
PingThread.FreeOnTerminate := False;
PingThread.Resume;
end;
end;
und hier der Thread
Delphi-Quellcode:
unit PingThread;
interface
uses
Windows, Classes, SysUtils, PingTest;
type
TPingThread =
class(TThread)
private
afHostName:
string;
aPing: Boolean;
procedure UpdateStaus;
procedure Finished;
procedure Abort;
protected
procedure Execute;
override;
procedure GetPing();
public
constructor Create(FHostname:
string);
end;
implementation
uses
MxMain;
constructor TPingThread.Create(fHostname:
string);
begin
inherited create(False);
priority:= tpTimeCritical;
FreeonTerminate:= False;
afHostName:= FHostname;
end;
procedure TPingThread.Abort;
begin
MxPlayer.Abort;
end;
procedure TPingThread.Execute;
begin
while not Terminated
do
begin
GetPing();
Sleep(1000);
end;
end;
procedure TPingThread.Finished;
begin
MxPlayer.Finished;
end;
procedure TPingThread.UpdateStaus;
begin
if self.Terminated
then
begin
Synchronize(Abort);
Exit;
end;
MxPlayer.UpdateStatus(aPing);
end;
procedure TPingThread.GetPing();
begin
if Self.Terminated
then
begin
Synchronize(Abort);
Exit;
end;
aPing:= Ping(afHostName);
Synchronize(UpdateStaus);
end;
end.
Schaun wir mal wo ich mist gebaut habe!
Gruß alfold