You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.1 KiB
Plaintext
57 lines
1.1 KiB
Plaintext
unit u_mymailThread;
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes;
|
|
|
|
type
|
|
TMyThread = class(TThread)
|
|
private
|
|
FOptype: string;
|
|
FMailQueNo: string;
|
|
FFlag: Boolean;
|
|
procedure SetOptype(const Value: string);
|
|
procedure SetMailQueNo(const Value: string);
|
|
|
|
procedure Myfun; // 原本的参数传递交由 TMyThread的实例赋值完成
|
|
protected
|
|
procedure Execute; override;
|
|
public
|
|
property Optype: string read FOptype write SetOptype;
|
|
property MailQueNo: string read FMailQueNo write SetMailQueNo;
|
|
property MyFunRetVal: Boolean read FFlag default False;
|
|
constructor Create(b: Boolean = True);
|
|
end;
|
|
|
|
implementation
|
|
|
|
procedure TMyThread.Myfun;
|
|
begin
|
|
// 假设这里做了操作UI的工作
|
|
FFlag := True;
|
|
end;
|
|
|
|
constructor TMyThread.Create(b: Boolean = True);
|
|
begin
|
|
inherited Create(b);
|
|
Self.FreeOnTerminate := True;
|
|
end;
|
|
|
|
procedure TMyThread.Execute;
|
|
begin
|
|
// 让操作UI的代码放回主线程中执行已保证同步
|
|
Synchronize(Myfun);
|
|
end;
|
|
|
|
procedure TMyThread.SetMailQueNo(const Value: string);
|
|
begin
|
|
FMailQueNo := Value;
|
|
end;
|
|
|
|
procedure TMyThread.SetOptype(const Value: string);
|
|
begin
|
|
FOptype := Value;
|
|
end;
|
|
end.
|