国产肉体XXXX裸体137大胆,国产成人久久精品流白浆,国产乱子伦视频在线观看,无码中文字幕免费一区二区三区 国产成人手机在线-午夜国产精品无套-swag国产精品-国产毛片久久国产

新聞中心

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

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

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

本文引用地址:http://m.ptau.cn/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);

  }

  /**////

  /// 開(kāi)始

  ///

  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í)器的定期行為將被禁用,但通過(guò)使用 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ù)專(zhuān)區(qū)

關(guān)閉