日本a√视频在线,久久青青亚洲国产,亚洲一区欧美二区,免费g片在线观看网站

        <style id="k3y6c"><u id="k3y6c"></u></style>
        <s id="k3y6c"></s>
        <mark id="k3y6c"></mark>
          
          

          <mark id="k3y6c"></mark>

          新聞中心

          EEPW首頁 > 消費電子 > 設計應用 > Timer定時器的設計方法

          Timer定時器的設計方法

          作者: 時間:2018-09-04 來源:網絡 收藏

          本文引用地址:http://yuyingmama.com.cn/article/201809/388353.htm

            /**////

            /// 委托

            ///

            private TimerCallback timerDelegate;

            /**////

            /// 靜態(tài)實例

            ///

            private static readonly PaperManager self = new PaperManager();

            /**////

            /// 構造函數(shù)

            ///

            public PaperManager()

            {

            timerDelegate = new TimerCallback(CheckStatus);

            }

            /**////

            ///

            ///

            ///

            public static PaperManager getInstance()

            {

            return self;

            }

            /**////

            /// 設置啟動時間間隔

            ///

            ///

            ///小時

            ///分鐘

            ///

            ///毫秒

            public void setDueTime(int days, int hours, int minutes, int seconds, int milisecond)

            {

            dueTime = new TimeSpan(days, hours, minutes, seconds, milisecond);

            }

            /**////

            /// 設置回調時間間隔

            ///

            ///

            ///小時

            ///分鐘

            ///

            ///毫秒

            public void setPeriod(int days, int hours, int minutes, int seconds, int milisecond)

            {

            period = new TimeSpan(days, hours, minutes, seconds, milisecond);

            }

            /**////

            /// 開始

            ///

            public void Start()

            {

            AutoResetEvent autoEvent = new AutoResetEvent(false);

            dueTime = TimeSpan.FromSeconds(0);

            period = TimeSpan.FromSeconds(10);

            iTimer = new Timer(timerDelegate, autoEvent, dueTime, period);

            autoEvent.WaitOne(5000, false);

            iTimer.Change(dueTime, period);

            }

            /**////

            /// 停止

            ///

            public void Stop()

            {

            iTimer.Dispose();

            }

            /**////

            /// 執(zhí)行一次

            ///

            public void ExcuteOneTime()

            {

            if (iTimer != null)

            {

            iTimer.Dispose();

            }

            //如果 period 為零 (0) 或 -1 毫秒,而且 dueTime 為正,則只會調用一次 callback;

            //計時器的定期行為將被禁用,但通過使用 Change 方法可以重新啟用該行為。

            setDueTime(0, 0, 0, 0, 1);

            setPeriod(0, 0, 0, 0, -1);

            AutoResetEvent autoEvent = new AutoResetEvent(false);

            iTimer = new Timer(timerDelegate, autoEvent, dueTime, period);

            autoEvent.WaitOne(5000, false);

            iTimer.Change(dueTime, period);

            }

            /**////

            /// 行為

            ///

            ///

            public void CheckStatus(object nObject)

            {

            AutoResetEvent autoEvent = (AutoResetEvent)nObject;



          關鍵詞:

          評論


          相關推薦

          技術專區(qū)

          關閉