C#Winform程序运行慢 程序运行起来,监视一下内存。或者用ants profile测试一下。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我觉得也是 winform怎么提高加载速度 GC.Collect()这个试下 强制程序释放过期变量 using资源的释放GC检查CPU等消耗情况 string GetTickCount(){int result = Environment.TickCount & Int32.MaxValue; TimeSpan tmp = new TimeSpan(Convert.ToInt64(Convert.ToInt64(result) * 10000)); //string workTime = tmp.Days + " 天 " + tmp.Hours + " 时 " + tmp.Minutes + " 分 " + tmp.Seconds + " 秒"; string workTime = string.Format("{0:00}", tmp.Days) + " 天 " + string.Format("{0:00}", tmp.Hours) + " 时 " + string.Format("{0:00}", tmp.Minutes) + " 分 " + string.Format("{0:00}", tmp.Seconds) + " 秒"; return workTime;}//窗体的Load里面:private void LoginUI_Load(object sender, EventArgs e){MethodInvoker mi = new MethodInvoker(delegate { lblMsg.Text = "电脑已工作------:" + Helper.GetTickCount(); });timer1 = new System.Timers.Timer(); timer1.Interval = 1000; timer1.Enabled = true;GC.Collect()timer1.Elapsed += delegate { this.lblMsg.Invoke(mi); GC.Collect(); };} 加个格式:string GetTickCount(){int result = Environment.TickCount & Int32.MaxValue; TimeSpan tmp = new TimeSpan(Convert.ToInt64(Convert.ToInt64(result) * 10000)); //string workTime = tmp.Days + " 天 " + tmp.Hours + " 时 " + tmp.Minutes + " 分 " + tmp.Seconds + " 秒"; string workTime = string.Format("{0:00}", tmp.Days) + " 天 " + string.Format("{0:00}", tmp.Hours) + " 时 " + string.Format("{0:00}", tmp.Minutes) + " 分 " + string.Format("{0:00}", tmp.Seconds) + " 秒"; return workTime;}//窗体的Load里面:private void LoginUI_Load(object sender, EventArgs e){MethodInvoker mi = new MethodInvoker(delegate { lblMsg.Text = "电脑已工作------:" + Helper.GetTickCount(); });timer1 = new System.Timers.Timer(); timer1.Interval = 1000; timer1.Enabled = true;GC.Collect()timer1.Elapsed += delegate { this.lblMsg.Invoke(mi); GC.Collect(); };} 两个窗体通信问题 为什么我的电脑上的VS2005 不会有错误提示框 枚举网上邻居共享文件夹的子文件夹问题 treeview结合数据库生成菜单问题--着急. 一句sql查询的功能,挑战一下你的sql 怎么样先判断一个string是不是英文构成的字符串?代码,谢谢。 求解:正则表达式替换掉(abc) winform Gridview 列宽度改变事件 海波大哥和诸位水晶报表高手过来帮忙啊!水晶报表中如何让详细资料区的内容一直打印到页面的底部!内详 ViewState[]是什么意思? 求助 API自动完成外部程序TREEVIEW的右键命令 如何设置dropdownlist下拉框的高度
这个试下 强制程序释放过期变量
资源的释放
GC
检查CPU等消耗情况
{
int result = Environment.TickCount & Int32.MaxValue;
TimeSpan tmp = new TimeSpan(Convert.ToInt64(Convert.ToInt64(result) * 10000));
//string workTime = tmp.Days + " 天 " + tmp.Hours + " 时 " + tmp.Minutes + " 分 " + tmp.Seconds + " 秒";
string workTime = string.Format("{0:00}", tmp.Days) + " 天 " + string.Format("{0:00}", tmp.Hours) + " 时 " + string.Format("{0:00}", tmp.Minutes) + " 分 " + string.Format("{0:00}", tmp.Seconds) + " 秒";
return workTime;
}
//窗体的Load里面:
private void LoginUI_Load(object sender, EventArgs e)
{
MethodInvoker mi = new MethodInvoker(delegate { lblMsg.Text = "电脑已工作------:" + Helper.GetTickCount(); });
timer1 = new System.Timers.Timer();
timer1.Interval = 1000;
timer1.Enabled = true;
GC.Collect()
timer1.Elapsed += delegate
{
this.lblMsg.Invoke(mi);
GC.Collect();
};
}
{
int result = Environment.TickCount & Int32.MaxValue;
TimeSpan tmp = new TimeSpan(Convert.ToInt64(Convert.ToInt64(result) * 10000));
//string workTime = tmp.Days + " 天 " + tmp.Hours + " 时 " + tmp.Minutes + " 分 " + tmp.Seconds + " 秒";
string workTime = string.Format("{0:00}", tmp.Days) + " 天 " + string.Format("{0:00}", tmp.Hours) + " 时 " + string.Format("{0:00}", tmp.Minutes) + " 分 " + string.Format("{0:00}", tmp.Seconds) + " 秒";
return workTime;
}
//窗体的Load里面:
private void LoginUI_Load(object sender, EventArgs e)
{
MethodInvoker mi = new MethodInvoker(delegate { lblMsg.Text = "电脑已工作------:" + Helper.GetTickCount(); });
timer1 = new System.Timers.Timer();
timer1.Interval = 1000;
timer1.Enabled = true;
GC.Collect()
timer1.Elapsed += delegate
{
this.lblMsg.Invoke(mi);
GC.Collect();
};
}