clstimeout.cs

来自「原创: 外挂网站刷IP程序的源码 自动ADSL拨号刷新IP,可录制鼠标模拟点」· CS 代码 · 共 65 行

CS
65
字号
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace qdog
{
    class clsTimeOut
    {
        Timer m_objTimer;
        int m_nTimes;
        Boolean m_bIsWork;
        const int MAX_TIMES = 60;

        public clsTimeOut()
        {
            m_objTimer = new Timer();
            m_objTimer.Tick += new EventHandler(m_objTimer_Tick);
        }

        void m_objTimer_Tick(object sender, EventArgs e)
        {
            m_nTimes++;
            //throw new Exception("The method or operation is not implemented.");
        }

        public void Wait(int nSec)
        {
            StartTime();
            Application.DoEvents();
            while (m_nTimes<nSec)
            {
                System.Threading.Thread.Sleep(1);
                Application.DoEvents();
                if (m_objTimer.Enabled == false)
                    break;
            }
            StopTime();
        }

        public void CancelWait()
        {
            StopTime();
        }

        private void StartTime()
        {
            m_bIsWork = true;
            m_nTimes = 0;
            m_objTimer.Interval = 1000;
            m_objTimer.Enabled = true;
            m_objTimer.Start();
        }

        private void StopTime()
        {
            m_bIsWork = false;
            m_objTimer.Stop();
            //m_objTimer.Interval = 0;
            m_objTimer.Enabled = false;
        }

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?