我正在制作一个单元,在该单元中我用BeginThread和一个在类中定义的变量抛出线程。在德尔福的一个单元中投掷线程
代码:
unit practica;
interface
uses Windows;
type
TTest = class
private
public
probando: integer;
procedure iniciar_thread;
procedure load_now;
end;
implementation
procedure TTest.load_now;
begin
Sleep(probando);
end;
procedure TTest.iniciar_thread;
begin
BeginThread(nil, 0, @TTest.load_now, nil, 0, PDWORD(0)^);
end;
end.
形式:
procedure TForm1.testClick(Sender: TObject);
test:TTest;
begin
test := TTest.Create();
test.probando := 1000;
test.iniciar_thread;
end;
当编译没有错误,但是当你运行的功能我得到这个:
Exception EAccessViolation in module test.exe
System Error. Code5
Runtime error 217
正如我解决这个问题?
你的意思是“投掷”在“发射”?我只是问,因为“throw”通常用于“抛出异常”的意义上...... – MartynA
在本机中使用BeginThread启动函数线程 – asdzxc
如果您的意思是*启动线程*,请写*启动线程* 。如果你说出你的意思,它会让你更容易理解你的问题。 :-) –