程序运行起来,监视一下内存。或者用ants profile测试一下。

解决方案 »

  1.   

    我觉得也是  winform怎么提高加载速度
      

  2.   

    GC.Collect()
    这个试下 强制程序释放过期变量
      

  3.   

    using
    资源的释放
    GC
    检查CPU等消耗情况
      

  4.   

    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();
                };
    }
      

  5.   

    加个格式: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();
      };
    }