我还有一个问题!请看看下面这个例子:如何在Delphi中将异常从一个线程传递到另一个线程(调用者的线程)?
// There is a class with some method:
type
TMyClass = class
public
procedure Proc1;
end;
// There is a some thread class:
TMyThread = class(TThread)
protected
procedure Execute; override;
end;
procedure TMyClass.Proc1;
begin
// this method is just calling another thread:
with TMyThread.Create(True) do
begin
FreeOnTerminate := True;
Resume;
end;
// + there are some more actions
end;
procedure TMyThread.Execute;
begin
// in this example this thread just throws exception:
raise Exception.Create('Some exception');
end;
所有我想要的东西 - 就是要引发的异常在TMyClass.Proc1并把它像这样:
var
myObject: TMyClass;
begin
myObject := TMyClass.Create;
try
myObject.Proc1; // launch and watch what happenings
except
on E: Exception do
WriteErrorLog(E.Message);
end;
FreeAndNil(myObject);
end;
请告诉我,我该怎么做的东西喜欢这个? 非常感谢!
哦!还有一件事 - 即时编码在德尔福5,所以我没有“FatalException”TThread的属性或有关..
您需要接受一个答案,或者如果没有足够完整的答案,您可以指示例如通过评论 – Remko 2010-09-29 11:27:08