中国开发网: 论坛: 程序员情感CBD: 贴子 84262
haibing_168: 应该是这样的。
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;


type
tyw = class
public
TmpIntA: integer;
TmpIntB: integer;
TmpIntC: integer;
end;

pyw = ^tyw;

type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
function ExecThread(tmpA,tmpB:integer):integer;
function GetSumAB(Tmpyw:pyw):integer;
end;

type
TMyThread = class(TThread)
private

protected
procedure Execute;override;
public
constructor Create(Tmpyw:pyw);virtual;

end;

var
Form1: TForm1;

implementation

{$R *.DFM}


function TForm1.ExecThread(tmpA,tmpB:integer):integer;
var
yw : pyw;
fyw: tyw;
begin
fyw := tyw.Create;
yw := @fyw;
fyw.TmpIntA := 1;
fyw.TmpIntB := 2;
if GetSumAB(yw) = 0 then //这里GetSumAB(yw)是一个函数
showmessage(IntToStr(yw.TmpIntC));
end;

function TForm1.GetSumAB(Tmpyw:pyw):integer;
begin
//这里创建一个线程,在线程中执行fyw.TmpIntA和fyw.TmpIntB的和,然后赋给fyw.TmpIntC
end;


constructor TMyThread.Create(Tmpyw:pyw);
begin
inherited Create(True);
//这里是线程创建时初始化的语句。
end;

procedure TMyThread.Execute;
begin
//线程执行的代码 
end;

end.

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录