为什么我的程序在OnCloseQuery和FormDestroy事件之间挂起? [英] Why does my program hang between OnCloseQuery and FormDestroy events?

查看:91
本文介绍了为什么我的程序在OnCloseQuery和FormDestroy事件之间挂起?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个中等复杂的程序,它使用了多个第三方组件,这些组件在Borland / Codegear / Embarcadero IDE的许多迭代中已经维护了20多年。最新的迭代(使用Delphi 2010)存在一个仅在某些用户的计算机上出现的问题,该计算机在关闭时停止响应。如果用户右键单击任务栏图标,然后再次选择关闭,程序将关闭。

I have a moderately complex program that uses several third party components that I have been maintaining for >20 years over many iterations of Borland/Codegear/Embarcadero IDE's. The latest iteration (using Delphi 2010) has a problem that appears only on some user's machines where it stops responding on shut down. If the user right clicks the Task Bar icon and selects "Close" again, the program will shut down.

我试图在自己的位置重现问题,但没有成功。我已经实现了各种日志记录方案,并且可以看到执行过程在FormCloseQuery过程之后但在FormDestroy事件之前停滞了。

I have tried to reproduce the problem at my location without success. I have implemented various logging schemes and can see that execution stalls after the FormCloseQuery procedure but before the FormDestroy event.

当用户启动关闭操作时,将执行多个表单和多个线程下。

There are multiple forms and several threads executing when the user initiates shut down.


  1. 我已检查线程是否正确终止。 (我在OnCloseQuery事件处理程序中将其关闭)

  2. 只有主窗体具有OnCloseQuery事件处理程序,并且我知道它以CanClose = true退出。

  3. 我记录了打开表单的完成代码,直到用户右键单击任务栏图标并再次选择关闭,它们都不会执行。

  4. 我已经检查了SysUtils.DoneMonitorSupport例程,该例程直到用户再次选择关闭后才运行。

  1. I have checked that my threads are terminating properly. (I close them in the OnCloseQuery event handler)
  2. Only the main form has an OnCloseQuery event handler and I know that it exits with CanClose = true.
  3. I logged the finalize code of the open forms and none of them execute until the user right clicks the taskbar icon and selects close again.
  4. I have checked the SysUtils.DoneMonitorSupport routine, it does not run until after the user selects close again.

我创建了一个小的调试程序,该程序注册Windows消息并显示有关应用程序的信息。这就是我看到的内容:

I created a little debug program that registers a windows message and displays information from the app in question. This is what I see:

Debug Message ID = 49681
7/28/2015 2:34:26 PM - MyApp initialized
7/28/2015 2:34:42 PM - Port opened COM3
7/28/2015 2:34:44 PM - Port opened COM5
7/28/2015 3:14:51 PM - Port closed COM3
7/28/2015 3:14:51 PM - Port closed COM5
7/28/2015 3:14:51 PM - MyApp closing (last line in MainForm.OnCloseQuery)
7/28/2015 3:14:51 PM - Configuration window destroy **stalls here**
7/28/2015 3:15:25 PM - Run Table destroy
7/28/2015 3:15:25 PM - Alert window destroy
7/28/2015 3:15:25 PM - Sample Table destroy
7/28/2015 3:15:25 PM - Debug window destroy
7/28/2015 3:15:25 PM - Main window destroy
7/28/2015 3:15:26 PM - Main window finalize

配置窗口创建并拥有多个子窗体。在配置窗口中的OnDestroy代码中,这些已释放,但是有对Application.ProcessMessages的调用。 (早在2000年代,就有一个问题,就是有时在表单被释放时会向其发送消息)。

The Configuration window creates and owns several child forms. In the Configuration window OnDestroy code these are freed, but there is a call to Application.ProcessMessages. (Back in the early 2000's there was a problem where sometimes a form would be sent a message while it was being freed) Could this be the problem?

推荐答案

在我的配置窗口的FormDestroy事件处理程序中调用了Application.ProcessMessages。在我将其取出后,客户尚未发现问题。

There was a call to Application.ProcessMessages in the FormDestroy event handler of my configuration window. After I took that out the customer has not seen the problem.

这篇关于为什么我的程序在OnCloseQuery和FormDestroy事件之间挂起?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆