CommonTimer.cs 961 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Threading;
  3. using MediaBrowser.Model.Threading;
  4. namespace Emby.Server.Implementations.Threading
  5. {
  6. public class CommonTimer : ITimer
  7. {
  8. private readonly Timer _timer;
  9. public CommonTimer(Action<object> callback, object state, TimeSpan dueTime, TimeSpan period)
  10. {
  11. _timer = new Timer(new TimerCallback(callback), state, dueTime, period);
  12. }
  13. public CommonTimer(Action<object> callback, object state, int dueTimeMs, int periodMs)
  14. {
  15. _timer = new Timer(new TimerCallback(callback), state, dueTimeMs, periodMs);
  16. }
  17. public void Change(TimeSpan dueTime, TimeSpan period)
  18. {
  19. _timer.Change(dueTime, period);
  20. }
  21. public void Change(int dueTimeMs, int periodMs)
  22. {
  23. _timer.Change(dueTimeMs, periodMs);
  24. }
  25. public void Dispose()
  26. {
  27. _timer.Dispose();
  28. }
  29. }
  30. }