SimpleTrigger.cs 647 B

1234567891011121314151617181920212223242526272829303132333435
  1. using CommonLang.IO;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. namespace CommonLang
  7. {
  8. public class SimpleTrigger
  9. {
  10. private long mNextTirggerTime;
  11. private int mInterval = 0;
  12. public SimpleTrigger(int interval)
  13. {
  14. this.mInterval = interval;
  15. this.Reset();
  16. }
  17. public void Reset()
  18. {
  19. this.mNextTirggerTime = CommonLang.CUtils.localTimeMS + this.mInterval;
  20. }
  21. public bool IsTrigger()
  22. {
  23. if(this.mNextTirggerTime < CommonLang.CUtils.localTimeMS)
  24. {
  25. this.mNextTirggerTime = CommonLang.CUtils.localTimeMS + this.mInterval;
  26. return true;
  27. }
  28. return false;
  29. }
  30. }
  31. }