这是一个C#应用程序,作为notifyicon坐在托盘中,并执行其任务,直到有人右键单击它并选择关闭(菜单选项)或它获取来自外部应用程序或操作系统的wm_close在重启过程中表示。如何检测区分外部wm_close与内部由form.close触发()
protected override void WndProc(ref Message m)
{
case Win32.WmClose:
//recvd message to shutdown
Program.Log.InfoFormat("Shutdown received at {0}", DateTime.Now);
CleanUp();
this.Close(); //this is the main form
break;
//other case statements here
}
//somewhere else on menu exit of notify icon
private void toolStripMenuItemExit_Click(object sender, EventArgs e)
{
Program.Log.InfoFormat("Manual EXIT at {0}", DateTime.Now);
CleanUp();
this.Close(); //this is the main form
}
this.close()触发另一个WM_CLOSE在tailspin中发送应用程序。处理这种情况的正确方法是什么?谢谢
Udpdate:或者在Wmclose而不是form.close()的情况下调用Application.exit也可以解决此问题。仅供参考。 – Gullu