Esempio n. 1
0
        private void ThreadCheckTime()
        {
            SetText("正在启动程序.......", lb_state);
            if (dp.Start())
            {
                SetText("运行中...", lb_state);
            }
            else
            {
                SetText("开始失败。", lb_state);
                return;
            }

            uint dt1 = LogInfo.Win32API.GetTickCount();

            while (bRun)
            {
                System.Threading.Thread.Sleep(500);
                try
                {
                    uint dt2 = LogInfo.Win32API.GetTickCount();
                    uint ts  = dt2 - dt1;
                    ts = ts / 1000;
                    if (ts > 3600)
                    {
                        int curHour = DateTime.Now.Hour;
                        if (curHour == LogInfo.Constant.SysRebootTime)
                        {
                            if (dp != null)
                            {
                                dp.Stop();
                            }
                            System.Threading.Thread.Sleep(10000);
                            System.Diagnostics.Process.Start(Application.StartupPath + "\\Monitor.exe");
                            dp = null;
                            break;
                        }
                    }

                    uint Seconds = ts % 60;
                    ts = (ts - Seconds) / 60;
                    uint Minutes = ts % 60;
                    ts = (ts - Minutes) / 60;
                    uint   Hours = ts % 24;
                    uint   Days  = (ts - Hours) / 24;
                    string msg   = "运行时间:" + Days.ToString() + "天"
                                   + Hours.ToString() + "小时" + Minutes.ToString() + "分" + Seconds.ToString() + "秒";
                    SetText(msg, lbRunTime);
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.ToString());
                }
            }
            if (bRun)
            {
                CloseWindow();
            }
        }