【发布时间】:2012-08-24 09:17:45
【问题描述】:
这是我的情况。我正在构建一个小型 Windows 窗体,它将在启动时启动并在不使用时在系统托盘中最小化运行。用户将通过系统托盘中的通知图标打开表单,提交表单后,应用程序将最小化回系统托盘。
这一切都很好。然而,我注意到了一些奇怪的事情。当程序首次启动时,任务管理器中的 Mem Usage 显示 ~14000 K。如果我从系统托盘打开表单,它会上升到 ~16000 K。如果我然后将表单最小化回系统托盘,使用率降至
我担心这个的原因是因为应用程序将在 Citrix 环境中运行,所以我想在应用程序不使用时降低每个实例的内存使用量,但我宁愿不必这样做让用户每天早上登录时打开应用程序并将其最小化。
如果有人有任何建议或提示,我将不胜感激。我将包括下面的主要代码块。
public Form1()
{
InitializeComponent();
WindowState = FormWindowState.Minimized;
notifyIcon1.DoubleClick += new EventHandler(notifyIcon1_DoubleClick);
Rectangle r = Screen.PrimaryScreen.WorkingArea;
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width, Screen.PrimaryScreen.WorkingArea.Height - this.Height);
currentWorkstation = Environment.GetEnvironmentVariable("clientname");
if (currentWorkstation == null)
currentWorkstation = Environment.MachineName;
GC.KeepAlive(notifyIcon1);
GC.KeepAlive(currentWorkstation);
}
private void Form1_Resize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
Hide();
}
感谢您的帮助。
【问题讨论】: