Mar*_*lka 12 delphi multithreading eoserror
我有个问题.我有一个使用线程的VCL应用程序.该线程进行一些计算,并通过Synchronize()调用MainForm的方法.一切正常,我有一个"开始"按钮,它创建并运行线程和一个"停止"按钮,停止并释放它.没有错误,没有任何错误.
但由于某些原因,当我关闭应用程序并且我运行该线程时,我得到了一个EOSError 1400 - Invalid window handle.我已经打破了OnClose程序,我在那里做的唯一事情是保存一个ini文件,没有错误,当我进一步追踪(使用F7)时,我到达最后(Application.Run; end.),在"调用"后end.我得到错误,因此没有特定的代码行提升它.
我希望这个问题有点清楚,我希望它是可以解决的,因为忽略错误似乎有点不洁净.
谢谢inb4
回答
当调用线程的Execute方法时,我发生了这个错误,它看起来像这样:
procedure TRunThread.Execute;
var (...)
begin
while not Terminated do begin
(...)
MainForm.Memo1.Lines.Add('Some text'); // Even though this call worked fine during
//the application running, it caused errors on shutting the app down.
// For acccessing GUI elements, it's necessary to use Synchronize()
(...)
end;
end;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9851 次 |
| 最近记录: |