定时更新内存和虚拟内存
public delegate void RefreshTextInvoke(Control control, string msg);
// 异步状态显示
private void RefreshText(Control control, string msg)
{
if (control.IsDisposed || this.IsDisposed) return;
if (control.InvokeRequired)
{
RefreshTextInvoke invoke = new RefreshTextInvoke(this.RefreshText);
this.BeginInvoke(invoke, new object[] { control, msg });
}
else
{
control.Text = msg;
}
}
Process pro = Process.GetCurrentProcess();
long ws = (pro.WorkingSet64) / 1024;
// (pro.PrivateMemorySize64) / 1024 (pro.VirtualMemorySize64) / 1024
long pms = (pro.PagedMemorySize64) / 1024;
string str = string.Format("内存:{0}K/虚拟内存:{1}K", ws.ToString("###,###"), pms.ToString("###,###"));
this.RefreshText(this, string.Format("我的IE - {0}", str));
// 异步状态显示
private void RefreshText(Control control, string msg)
{
if (control.IsDisposed || this.IsDisposed) return;
if (control.InvokeRequired)
{
RefreshTextInvoke invoke = new RefreshTextInvoke(this.RefreshText);
this.BeginInvoke(invoke, new object[] { control, msg });
}
else
{
control.Text = msg;
}
}
Process pro = Process.GetCurrentProcess();
long ws = (pro.WorkingSet64) / 1024;
// (pro.PrivateMemorySize64) / 1024 (pro.VirtualMemorySize64) / 1024
long pms = (pro.PagedMemorySize64) / 1024;
string str = string.Format("内存:{0}K/虚拟内存:{1}K", ws.ToString("###,###"), pms.ToString("###,###"));
this.RefreshText(this, string.Format("我的IE - {0}", str));