我有一份显示大多数时间形式的数字,我需要当用户关闭该系统时,自己结束。
因此,我设立了a 问题,以及该系统的答复。 开会似乎奏效。
首先。
我的<代码>Program.Main()方法:
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
#region Pre-launch stuff
// Are we upgrading from an older version? We need to grab our old settings!
if (Properties.Settings.Default.UpgradeSettings)
{
Properties.Settings.Default.Upgrade();
Properties.Settings.Default.UpgradeSettings = false;
Properties.Settings.Default.Save();
}
// Visual styles
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
#if !DEBUG
// Add the event handler for handling UI thread exceptions to the event.
Application.ThreadException += new ThreadExceptionEventHandler(ErrorHandling.Application_ThreadException);
// Set the unhandled exception mode to force all Windows Forms errors to go through our handler.
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
// Add the event handler for handling non-UI thread exceptions to the event.
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ErrorHandling.CurrentDomain_UnhandledException);
#endif
// Since we have no forms open we need to watch for the shutdown event; otherwise we re blocking it
SystemEvents.SessionEnding += new SessionEndingEventHandler(SystemEvents_SessionEnding);
// ...
// ...
// ...
Application.Run();
}
方法SystemEvents_SessionEnding
a. 采用<代码>Exit(<>Exit()”的方法。
public static void Exit()
{
MessageBox.Show("test");
try
{
IconHandler.SuperNotifyIcon.Dispose();
}
finally
{
Application.Exit();
}
}
然而,我的 app子有时关闭。 我补充说的信息箱没有显示。
我可以指出,这种简单、简单的执行道路可能失败。 但是,它确实如此,这对我和我的用户来说都是一个很大的刺激。
任何想法? Though倒?
http://www.un.org。
Per corvuscorax s response, I ve试图增加一个表格,但行动迟缓——首先,我有这样的文字:
ShowInTaskbar = false;
WindowState = FormWindowState.Minimized;
Shown += (sender, e) => Hide();
并修改了<代码>Program.Exit()方法,以关闭该表,该表将同时在<代码>上操作处置代码。 表格Closing activity。
该表格从接收