CommonTimer.cs 1.0 KB

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