unit
uNewThread;
interface
uses
System
.
Classes,SysUtils,Dialogs,SyncObjs,StrUtils,ExtCtrls,Windows,
WideStrUtils,Vcl
.
Forms;
procedure
ThreadDoJob(
const
aHost:
string
;
var
aErrorMsg:
string
;
var
aIsJobDone:
Boolean
);
type
DoJob =
class
(TThread)
private
fHost,fErrorMsg:
string
;
fIsJobDone:
Boolean
;
protected
procedure
Execute; override;
public
property
ErrorMsg:
string
read fErrorMsg;
property
IsJobDone:
Boolean
read fIsJobDone;
constructor
Create(
const
aHost:
string
;
var
aErrorMsg:
string
;
var
aIsJobDone:
Boolean
);
destructor
Destroy; override;
end
;
implementation
procedure
ThreadDoJob(
const
aHost:
string
;
var
aErrorMsg:
string
;
var
aIsJobDone:
Boolean
);
var
ThreadJob:DoJob;
begin
ThreadJob:=DoJob
.
Create(aHost,aErrorMsg,aIsJobDone);
aErrorMsg:=ThreadJob
.
ErrorMsg;
aIsJobDone:=ThreadJob
.
IsJobDone;
end
;
constructor
DoJob
.
Create(
const
aHost:
string
;
var
aErrorMsg:
string
;
var
aIsJobDone:
Boolean
);
begin
inherited
Create(
False
);
FreeOnTerminate :=
True
;
Self
.
Priority := tpLower;
fHost:=aHost;
end
;
destructor
DoJob
.
Destroy;
begin
inherited
Destroy;
end
;
procedure
DoJob
.
Execute;
var
flg:
Boolean
;
begin
flg:=
true
;
if
flg
then
begin
fIsJobDone:=
TRUE
;
fErrorMsg:=
'7777'
;
end
else
begin
fIsJobDone:=
FALSE
;
fErrorMsg:=
'6666'
;
end
;
end
.