From bfcd1b520fd79b893e721ba916ae5e1656407d2f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 16 Aug 2017 02:43:41 -0400 Subject: merge common implementations and server implementations --- .../Threading/CommonTimer.cs | 36 ++++++++++++++++++++++ .../Threading/TimerFactory.cs | 18 +++++++++++ 2 files changed, 54 insertions(+) create mode 100644 Emby.Server.Implementations/Threading/CommonTimer.cs create mode 100644 Emby.Server.Implementations/Threading/TimerFactory.cs (limited to 'Emby.Server.Implementations/Threading') diff --git a/Emby.Server.Implementations/Threading/CommonTimer.cs b/Emby.Server.Implementations/Threading/CommonTimer.cs new file mode 100644 index 000000000..9451b07f3 --- /dev/null +++ b/Emby.Server.Implementations/Threading/CommonTimer.cs @@ -0,0 +1,36 @@ +using System; +using System.Threading; +using MediaBrowser.Model.Threading; + +namespace Emby.Server.Implementations.Threading +{ + public class CommonTimer : ITimer + { + private readonly Timer _timer; + + public CommonTimer(Action callback, object state, TimeSpan dueTime, TimeSpan period) + { + _timer = new Timer(new TimerCallback(callback), state, dueTime, period); + } + + public CommonTimer(Action callback, object state, int dueTimeMs, int periodMs) + { + _timer = new Timer(new TimerCallback(callback), state, dueTimeMs, periodMs); + } + + public void Change(TimeSpan dueTime, TimeSpan period) + { + _timer.Change(dueTime, period); + } + + public void Change(int dueTimeMs, int periodMs) + { + _timer.Change(dueTimeMs, periodMs); + } + + public void Dispose() + { + _timer.Dispose(); + } + } +} diff --git a/Emby.Server.Implementations/Threading/TimerFactory.cs b/Emby.Server.Implementations/Threading/TimerFactory.cs new file mode 100644 index 000000000..4ab6f6fc4 --- /dev/null +++ b/Emby.Server.Implementations/Threading/TimerFactory.cs @@ -0,0 +1,18 @@ +using System; +using MediaBrowser.Model.Threading; + +namespace Emby.Server.Implementations.Threading +{ + public class TimerFactory : ITimerFactory + { + public ITimer Create(Action callback, object state, TimeSpan dueTime, TimeSpan period) + { + return new CommonTimer(callback, state, dueTime, period); + } + + public ITimer Create(Action callback, object state, int dueTimeMs, int periodMs) + { + return new CommonTimer(callback, state, dueTimeMs, periodMs); + } + } +} -- cgit v1.2.3