在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 消費(fèi)電子 > 設(shè)計(jì)應(yīng)用 > Timer定時(shí)器的設(shè)計(jì)方法

            Timer定時(shí)器的設(shè)計(jì)方法

            作者: 時(shí)間:2018-09-04 來源:網(wǎng)絡(luò) 收藏

            本文引用地址:http://www.biyoush.com/article/201809/388353.htm

              /**////

              /// 委托

              ///

              private TimerCallback timerDelegate;

              /**////

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

              ///

              private static readonly PaperManager self = new PaperManager();

              /**////

              /// 構(gòu)造函數(shù)

              ///

              public PaperManager()

              {

              timerDelegate = new TimerCallback(CheckStatus);

              }

              /**////

              ///

              ///

              ///

              public static PaperManager getInstance()

              {

              return self;

              }

              /**////

              /// 設(shè)置啟動(dòng)時(shí)間間隔

              ///

              ///

              ///小時(shí)

              ///分鐘

              ///

              ///毫秒

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

              {

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

              }

              /**////

              /// 設(shè)置回調(diào)時(shí)間間隔

              ///

              ///

              ///小時(shí)

              ///分鐘

              ///

              ///毫秒

              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 為正,則只會(huì)調(diào)用一次 callback;

              //計(jì)時(shí)器的定期行為將被禁用,但通過使用 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;



            關(guān)鍵詞:

            評(píng)論


            相關(guān)推薦

            技術(shù)專區(qū)

            關(guān)閉