The Free Software Media System - Server Backend & API
Remove custom Threading
Claus Vium0ef2b4610693
diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.csindex 7398b24cd8..a200065782 100644--- a/Emby.Dlna/Main/DlnaEntryPoint.cs+++ b/Emby.Dlna/Main/DlnaEntryPoint.cs@@ -20,7 +20,6 @@ using MediaBrowser.Model.Dlna;using MediaBrowser.Model.Globalization;using MediaBrowser.Model.Net;using MediaBrowser.Model.System;-using MediaBrowser.Model.Threading;using MediaBrowser.Model.Xml;using Microsoft.Extensions.Logging;using Rssdp;@@ -49,8 +48,7 @@ namespace Emby.Dlna.Mainprivate readonly IDeviceDiscovery _deviceDiscovery;private SsdpDevicePublisher _Publisher;-- private readonly ITimerFactory _timerFactory;+private readonly ISocketFactory _socketFactory;private readonly IEnvironmentInfo _environmentInfo;private readonly INetworkManager _networkManager;@@ -78,7 +76,6 @@ namespace Emby.Dlna.MainIDeviceDiscovery deviceDiscovery,IMediaEncoder mediaEncoder,ISocketFactory socketFactory,- ITimerFactory timerFactory,IEnvironmentInfo environmentInfo,INetworkManager networkManager,IUserViewManager userViewManager,@@ -99,7 +96,6 @@ namespace Emby.Dlna.Main_deviceDiscovery = deviceDiscovery;_mediaEncoder = mediaEncoder;_socketFactory = socketFactory;- _timerFactory = timerFactory;_environmentInfo = environmentInfo;_networkManager = networkManager;_logger = loggerFactory.CreateLogger("Dlna");@@ -233,7 +229,7 @@ namespace Emby.Dlna.Maintry{- _Publisher = new SsdpDevicePublisher(_communicationsServer, _timerFactory, _environmentInfo.OperatingSystemName, _environmentInfo.OperatingSystemVersion);+ _Publisher = new SsdpDevicePublisher(_communicationsServer, _environmentInfo.OperatingSystemName, _environmentInfo.OperatingSystemVersion);_Publisher.LogFunction = LogMessage;_Publisher.SupportPnpRootDevice = false;@@ -353,8 +349,7 @@ namespace Emby.Dlna.Main_userDataManager,_localization,_mediaSourceManager,- _mediaEncoder,- _timerFactory);+ _mediaEncoder);_manager.Start();}diff --git a/Emby.Dlna/PlayTo/Device.cs b/Emby.Dlna/PlayTo/Device.csindex 85a522d1cc..e49168d34b 100644--- a/Emby.Dlna/PlayTo/Device.cs+++ b/Emby.Dlna/PlayTo/Device.cs@@ -10,7 +10,6 @@ using Emby.Dlna.Server;using Emby.Dlna.Ssdp;using MediaBrowser.Common.Net;using MediaBrowser.Controller.Configuration;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace Emby.Dlna.PlayTo@@ -19,7 +18,7 @@ namespace Emby.Dlna.PlayTo{#region Fields & Properties- private ITimer _timer;+ private Timer _timer;public DeviceInfo Properties { get; set; }@@ -64,21 +63,18 @@ namespace Emby.Dlna.PlayTopublic DateTime DateLastActivity { get; private set; }public Action OnDeviceUnavailable { get; set; }- private readonly ITimerFactory _timerFactory;-- public Device(DeviceInfo deviceProperties, IHttpClient httpClient, ILogger logger, IServerConfigurationManager config, ITimerFactory timerFactory)+ public Device(DeviceInfo deviceProperties, IHttpClient httpClient, ILogger logger, IServerConfigurationManager config){Properties = deviceProperties;_httpClient = httpClient;_logger = logger;_config = config;- _timerFactory = timerFactory;}public void Start(){_logger.LogDebug("Dlna Device.Start");- _timer = _timerFactory.Create(TimerCallback, null, 1000, Timeout.Infinite);+ _timer = new Timer(TimerCallback, null, 1000, Timeout.Infinite);}private DateTime _lastVolumeRefresh;@@ -890,7 +886,7 @@ namespace Emby.Dlna.PlayToset;}- public static async Task<Device> CreateuPnpDeviceAsync(Uri url, IHttpClient httpClient, IServerConfigurationManager config, ILogger logger, ITimerFactory timerFactory, CancellationToken cancellationToken)+ public static async Task<Device> CreateuPnpDeviceAsync(Uri url, IHttpClient httpClient, IServerConfigurationManager config, ILogger logger, CancellationToken cancellationToken){var ssdpHttpClient = new SsdpHttpClient(httpClient, config);@@ -1001,7 +997,7 @@ namespace Emby.Dlna.PlayTo}}- var device = new Device(deviceProperties, httpClient, logger, config, timerFactory);+ var device = new Device(deviceProperties, httpClient, logger, config);return device;}diff --git a/Emby.Dlna/PlayTo/PlayToManager.cs b/Emby.Dlna/PlayTo/PlayToManager.csindex 790625705a..6cce312eef 100644--- a/Emby.Dlna/PlayTo/PlayToManager.cs+++ b/Emby.Dlna/PlayTo/PlayToManager.cs@@ -16,7 +16,6 @@ using MediaBrowser.Model.Events;using MediaBrowser.Model.Globalization;using MediaBrowser.Model.Net;using MediaBrowser.Model.Session;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace Emby.Dlna.PlayTo@@ -39,13 +38,12 @@ namespace Emby.Dlna.PlayToprivate readonly IDeviceDiscovery _deviceDiscovery;private readonly IMediaSourceManager _mediaSourceManager;private readonly IMediaEncoder _mediaEncoder;- private readonly ITimerFactory _timerFactory;private bool _disposed;private SemaphoreSlim _sessionLock = new SemaphoreSlim(1, 1);private CancellationTokenSource _disposeCancellationTokenSource = new CancellationTokenSource();- public PlayToManager(ILogger logger, ISessionManager sessionManager, ILibraryManager libraryManager, IUserManager userManager, IDlnaManager dlnaManager, IServerApplicationHost appHost, IImageProcessor imageProcessor, IDeviceDiscovery deviceDiscovery, IHttpClient httpClient, IServerConfigurationManager config, IUserDataManager userDataManager, ILocalizationManager localization, IMediaSourceManager mediaSourceManager, IMediaEncoder mediaEncoder, ITimerFactory timerFactory)+ public PlayToManager(ILogger logger, ISessionManager sessionManager, ILibraryManager libraryManager, IUserManager userManager, IDlnaManager dlnaManager, IServerApplicationHost appHost, IImageProcessor imageProcessor, IDeviceDiscovery deviceDiscovery, IHttpClient httpClient, IServerConfigurationManager config, IUserDataManager userDataManager, ILocalizationManager localization, IMediaSourceManager mediaSourceManager, IMediaEncoder mediaEncoder){_logger = logger;_sessionManager = sessionManager;@@ -61,7 +59,6 @@ namespace Emby.Dlna.PlayTo_localization = localization;_mediaSourceManager = mediaSourceManager;_mediaEncoder = mediaEncoder;- _timerFactory = timerFactory;}public void Start()@@ -168,7 +165,7 @@ namespace Emby.Dlna.PlayToif (controller == null){- var device = await Device.CreateuPnpDeviceAsync(uri, _httpClient, _config, _logger, _timerFactory, cancellationToken).ConfigureAwait(false);+ var device = await Device.CreateuPnpDeviceAsync(uri, _httpClient, _config, _logger, cancellationToken).ConfigureAwait(false);string deviceName = device.Properties.Name;diff --git a/Emby.Dlna/Ssdp/DeviceDiscovery.cs b/Emby.Dlna/Ssdp/DeviceDiscovery.csindex 89a88705f4..298f68a28e 100644--- a/Emby.Dlna/Ssdp/DeviceDiscovery.cs+++ b/Emby.Dlna/Ssdp/DeviceDiscovery.cs@@ -5,7 +5,6 @@ using MediaBrowser.Controller.Configuration;using MediaBrowser.Model.Dlna;using MediaBrowser.Model.Events;using MediaBrowser.Model.Net;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;using Rssdp;using Rssdp.Infrastructure;@@ -48,20 +47,17 @@ namespace Emby.Dlna.Ssdpprivate SsdpDeviceLocator _deviceLocator;- private readonly ITimerFactory _timerFactory;private readonly ISocketFactory _socketFactory;private ISsdpCommunicationsServer _commsServer;public DeviceDiscovery(ILoggerFactory loggerFactory,IServerConfigurationManager config,- ISocketFactory socketFactory,- ITimerFactory timerFactory)+ ISocketFactory socketFactory){_logger = loggerFactory.CreateLogger(nameof(DeviceDiscovery));_config = config;_socketFactory = socketFactory;- _timerFactory = timerFactory;}// Call this method from somewhere in your code to start the search.@@ -78,7 +74,7 @@ namespace Emby.Dlna.Ssdp{if (_listenerCount > 0 && _deviceLocator == null){- _deviceLocator = new SsdpDeviceLocator(_commsServer, _timerFactory);+ _deviceLocator = new SsdpDeviceLocator(_commsServer);// (Optional) Set the filter so we only see notifications for devices we care about// (can be any search target value i.e device type, uuid value etc - any value that appears in thediff --git a/Emby.Notifications/Notifications.cs b/Emby.Notifications/Notifications.csindex 045aa6f16d..d3290479f4 100644--- a/Emby.Notifications/Notifications.cs+++ b/Emby.Notifications/Notifications.cs@@ -20,7 +20,6 @@ using MediaBrowser.Model.Events;using MediaBrowser.Model.Globalization;using MediaBrowser.Model.Notifications;using MediaBrowser.Model.Tasks;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace Emby.Notifications@@ -40,9 +39,8 @@ namespace Emby.Notificationsprivate readonly ILibraryManager _libraryManager;private readonly ISessionManager _sessionManager;private readonly IServerApplicationHost _appHost;- private readonly ITimerFactory _timerFactory;- private ITimer LibraryUpdateTimer { get; set; }+ private Timer LibraryUpdateTimer { get; set; }private readonly object _libraryChangedSyncLock = new object();private readonly IConfigurationManager _config;@@ -52,7 +50,7 @@ namespace Emby.Notificationsprivate string[] _coreNotificationTypes;- public Notifications(IInstallationManager installationManager, IActivityManager activityManager, ILocalizationManager localization, IUserManager userManager, ILogger logger, ITaskManager taskManager, INotificationManager notificationManager, ILibraryManager libraryManager, ISessionManager sessionManager, IServerApplicationHost appHost, IConfigurationManager config, IDeviceManager deviceManager, ITimerFactory timerFactory)+ public Notifications(IInstallationManager installationManager, IActivityManager activityManager, ILocalizationManager localization, IUserManager userManager, ILogger logger, ITaskManager taskManager, INotificationManager notificationManager, ILibraryManager libraryManager, ISessionManager sessionManager, IServerApplicationHost appHost, IConfigurationManager config, IDeviceManager deviceManager){_installationManager = installationManager;_userManager = userManager;@@ -64,7 +62,6 @@ namespace Emby.Notifications_appHost = appHost;_config = config;_deviceManager = deviceManager;- _timerFactory = timerFactory;_localization = localization;_activityManager = activityManager;@@ -159,7 +156,7 @@ namespace Emby.Notifications{if (LibraryUpdateTimer == null){- LibraryUpdateTimer = _timerFactory.Create(LibraryUpdateTimerCallback, null, 5000,+ LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, 5000,Timeout.Infinite);}elsediff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.csindex 365eb58564..3808810cfa 100644--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@ -43,7 +43,6 @@ using Emby.Server.Implementations.ScheduledTasks;using Emby.Server.Implementations.Security;using Emby.Server.Implementations.Serialization;using Emby.Server.Implementations.Session;-using Emby.Server.Implementations.Threading;using Emby.Server.Implementations.TV;using Emby.Server.Implementations.Updates;using Emby.Server.Implementations.Xml;@@ -99,7 +98,6 @@ using MediaBrowser.Model.Serialization;using MediaBrowser.Model.Services;using MediaBrowser.Model.System;using MediaBrowser.Model.Tasks;-using MediaBrowser.Model.Threading;using MediaBrowser.Model.Updates;using MediaBrowser.Model.Xml;using MediaBrowser.Providers.Chapters;@@ -347,7 +345,6 @@ namespace Emby.Server.Implementationsinternal IImageEncoder ImageEncoder { get; private set; }protected IProcessFactory ProcessFactory { get; private set; }- protected ITimerFactory TimerFactory { get; private set; }protected ICryptoProvider CryptographyProvider = new CryptographyProvider();protected readonly IXmlSerializer XmlSerializer;@@ -772,9 +769,6 @@ namespace Emby.Server.ImplementationsProcessFactory = new ProcessFactory();RegisterSingleInstance(ProcessFactory);- TimerFactory = new TimerFactory();- RegisterSingleInstance(TimerFactory);-var streamHelper = CreateStreamHelper();ApplicationHost.StreamHelper = streamHelper;RegisterSingleInstance(streamHelper);@@ -837,7 +831,7 @@ namespace Emby.Server.Implementationsvar musicManager = new MusicManager(LibraryManager);RegisterSingleInstance<IMusicManager>(new MusicManager(LibraryManager));- LibraryMonitor = new LibraryMonitor(LoggerFactory, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager, TimerFactory, EnvironmentInfo);+ LibraryMonitor = new LibraryMonitor(LoggerFactory, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager, EnvironmentInfo);RegisterSingleInstance(LibraryMonitor);RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LoggerFactory, LibraryManager, UserManager));@@ -869,7 +863,7 @@ namespace Emby.Server.ImplementationsDeviceManager = new DeviceManager(AuthenticationRepository, JsonSerializer, LibraryManager, LocalizationManager, UserManager, FileSystemManager, LibraryMonitor, ServerConfigurationManager, LoggerFactory, NetworkManager);RegisterSingleInstance(DeviceManager);- MediaSourceManager = new MediaSourceManager(ItemRepository, ApplicationPaths, LocalizationManager, UserManager, LibraryManager, LoggerFactory, JsonSerializer, FileSystemManager, UserDataManager, TimerFactory, () => MediaEncoder);+ MediaSourceManager = new MediaSourceManager(ItemRepository, ApplicationPaths, LocalizationManager, UserManager, LibraryManager, LoggerFactory, JsonSerializer, FileSystemManager, UserDataManager, () => MediaEncoder);RegisterSingleInstance(MediaSourceManager);SubtitleManager = new SubtitleManager(LoggerFactory, FileSystemManager, LibraryMonitor, MediaSourceManager, LocalizationManager);@@ -884,7 +878,7 @@ namespace Emby.Server.ImplementationsChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, LoggerFactory, ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient, ProviderManager);RegisterSingleInstance(ChannelManager);- SessionManager = new SessionManager(UserDataManager, LoggerFactory, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager, TimerFactory);+ SessionManager = new SessionManager(UserDataManager, LoggerFactory, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager, MediaSourceManager);RegisterSingleInstance(SessionManager);var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LoggerFactory, JsonSerializer, this, assemblyInfo);@@ -905,7 +899,7 @@ namespace Emby.Server.ImplementationsNotificationManager = new NotificationManager(LoggerFactory, UserManager, ServerConfigurationManager);RegisterSingleInstance(NotificationManager);- RegisterSingleInstance<IDeviceDiscovery>(new DeviceDiscovery(LoggerFactory, ServerConfigurationManager, SocketFactory, TimerFactory));+ RegisterSingleInstance<IDeviceDiscovery>(new DeviceDiscovery(LoggerFactory, ServerConfigurationManager, SocketFactory));ChapterManager = new ChapterManager(LibraryManager, LoggerFactory, ServerConfigurationManager, ItemRepository);RegisterSingleInstance(ChapterManager);diff --git a/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs b/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.csindex 361656ff2f..19ea093594 100644--- a/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs+++ b/Emby.Server.Implementations/EntryPoints/AutomaticRestartEntryPoint.cs@@ -9,7 +9,6 @@ using MediaBrowser.Controller.Plugins;using MediaBrowser.Controller.Session;using MediaBrowser.Model.LiveTv;using MediaBrowser.Model.Tasks;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace Emby.Server.Implementations.EntryPoints@@ -22,11 +21,10 @@ namespace Emby.Server.Implementations.EntryPointsprivate readonly ISessionManager _sessionManager;private readonly IServerConfigurationManager _config;private readonly ILiveTvManager _liveTvManager;- private readonly ITimerFactory _timerFactory;- private ITimer _timer;+ private Timer _timer;- public AutomaticRestartEntryPoint(IServerApplicationHost appHost, ILogger logger, ITaskManager iTaskManager, ISessionManager sessionManager, IServerConfigurationManager config, ILiveTvManager liveTvManager, ITimerFactory timerFactory)+ public AutomaticRestartEntryPoint(IServerApplicationHost appHost, ILogger logger, ITaskManager iTaskManager, ISessionManager sessionManager, IServerConfigurationManager config, ILiveTvManager liveTvManager){_appHost = appHost;_logger = logger;@@ -34,7 +32,6 @@ namespace Emby.Server.Implementations.EntryPoints_sessionManager = sessionManager;_config = config;_liveTvManager = liveTvManager;- _timerFactory = timerFactory;}public Task RunAsync()@@ -53,7 +50,7 @@ namespace Emby.Server.Implementations.EntryPointsif (_appHost.HasPendingRestart){- _timer = _timerFactory.Create(TimerCallback, null, TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(15));+ _timer = new Timer(TimerCallback, null, TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(15));}}diff --git a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.csindex 56c730c800..f26a705867 100644--- a/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs+++ b/Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs@@ -10,7 +10,6 @@ using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Plugins;using MediaBrowser.Model.Dlna;using MediaBrowser.Model.Events;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;using Mono.Nat;@@ -24,19 +23,17 @@ namespace Emby.Server.Implementations.EntryPointsprivate readonly IServerConfigurationManager _config;private readonly IDeviceDiscovery _deviceDiscovery;- private ITimer _timer;- private readonly ITimerFactory _timerFactory;+ private Timer _timer;private NatManager _natManager;- public ExternalPortForwarding(ILoggerFactory loggerFactory, IServerApplicationHost appHost, IServerConfigurationManager config, IDeviceDiscovery deviceDiscovery, IHttpClient httpClient, ITimerFactory timerFactory)+ public ExternalPortForwarding(ILoggerFactory loggerFactory, IServerApplicationHost appHost, IServerConfigurationManager config, IDeviceDiscovery deviceDiscovery, IHttpClient httpClient){_logger = loggerFactory.CreateLogger("PortMapper");_appHost = appHost;_config = config;_deviceDiscovery = deviceDiscovery;_httpClient = httpClient;- _timerFactory = timerFactory;_config.ConfigurationUpdated += _config_ConfigurationUpdated1;}@@ -94,7 +91,7 @@ namespace Emby.Server.Implementations.EntryPoints_natManager.StartDiscovery();}- _timer = _timerFactory.Create(ClearCreatedRules, null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10));+ _timer = new Timer(ClearCreatedRules, null, TimeSpan.FromMinutes(10), TimeSpan.FromMinutes(10));_deviceDiscovery.DeviceDiscovered += _deviceDiscovery_DeviceDiscovered;diff --git a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.csindex 9b61809c75..0389656477 100644--- a/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs+++ b/Emby.Server.Implementations/EntryPoints/LibraryChangedNotifier.cs@@ -14,7 +14,6 @@ using MediaBrowser.Controller.Session;using MediaBrowser.Model.Entities;using MediaBrowser.Model.Events;using MediaBrowser.Model.Extensions;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace Emby.Server.Implementations.EntryPoints@@ -29,7 +28,6 @@ namespace Emby.Server.Implementations.EntryPointsprivate readonly ISessionManager _sessionManager;private readonly IUserManager _userManager;private readonly ILogger _logger;- private readonly ITimerFactory _timerFactory;/// <summary>/// The _library changed sync lock@@ -47,7 +45,7 @@ namespace Emby.Server.Implementations.EntryPoints/// Gets or sets the library update timer./// </summary>/// <value>The library update timer.</value>- private ITimer LibraryUpdateTimer { get; set; }+ private Timer LibraryUpdateTimer { get; set; }/// <summary>/// The library update duration@@ -56,13 +54,12 @@ namespace Emby.Server.Implementations.EntryPointsprivate readonly IProviderManager _providerManager;- public LibraryChangedNotifier(ILibraryManager libraryManager, ISessionManager sessionManager, IUserManager userManager, ILogger logger, ITimerFactory timerFactory, IProviderManager providerManager)+ public LibraryChangedNotifier(ILibraryManager libraryManager, ISessionManager sessionManager, IUserManager userManager, ILogger logger, IProviderManager providerManager){_libraryManager = libraryManager;_sessionManager = sessionManager;_userManager = userManager;_logger = logger;- _timerFactory = timerFactory;_providerManager = providerManager;}@@ -191,7 +188,7 @@ namespace Emby.Server.Implementations.EntryPoints{if (LibraryUpdateTimer == null){- LibraryUpdateTimer = _timerFactory.Create(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,+ LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,Timeout.Infinite);}else@@ -225,7 +222,7 @@ namespace Emby.Server.Implementations.EntryPoints{if (LibraryUpdateTimer == null){- LibraryUpdateTimer = _timerFactory.Create(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,+ LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,Timeout.Infinite);}else@@ -253,7 +250,7 @@ namespace Emby.Server.Implementations.EntryPoints{if (LibraryUpdateTimer == null){- LibraryUpdateTimer = _timerFactory.Create(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,+ LibraryUpdateTimer = new Timer(LibraryUpdateTimerCallback, null, LibraryUpdateDuration,Timeout.Infinite);}elsediff --git a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.csindex d91a2d5817..774ed09dab 100644--- a/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs+++ b/Emby.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs@@ -10,7 +10,6 @@ using MediaBrowser.Controller.Session;using MediaBrowser.Model.Entities;using MediaBrowser.Model.Extensions;using MediaBrowser.Model.Session;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace Emby.Server.Implementations.EntryPoints@@ -23,19 +22,17 @@ namespace Emby.Server.Implementations.EntryPointsprivate readonly IUserManager _userManager;private readonly object _syncLock = new object();- private ITimer UpdateTimer { get; set; }- private readonly ITimerFactory _timerFactory;+ private Timer UpdateTimer { get; set; }private const int UpdateDuration = 500;private readonly Dictionary<Guid, List<BaseItem>> _changedItems = new Dictionary<Guid, List<BaseItem>>();- public UserDataChangeNotifier(IUserDataManager userDataManager, ISessionManager sessionManager, ILogger logger, IUserManager userManager, ITimerFactory timerFactory)+ public UserDataChangeNotifier(IUserDataManager userDataManager, ISessionManager sessionManager, ILogger logger, IUserManager userManager){_userDataManager = userDataManager;_sessionManager = sessionManager;_logger = logger;_userManager = userManager;- _timerFactory = timerFactory;}public Task RunAsync()@@ -56,7 +53,7 @@ namespace Emby.Server.Implementations.EntryPoints{if (UpdateTimer == null){- UpdateTimer = _timerFactory.Create(UpdateTimerCallback, null, UpdateDuration,+ UpdateTimer = new Timer(UpdateTimerCallback, null, UpdateDuration,Timeout.Infinite);}elsediff --git a/Emby.Server.Implementations/IO/FileRefresher.cs b/Emby.Server.Implementations/IO/FileRefresher.csindex 1cac0ba5c4..3668f6a7ab 100644--- a/Emby.Server.Implementations/IO/FileRefresher.cs+++ b/Emby.Server.Implementations/IO/FileRefresher.cs@@ -2,6 +2,7 @@ using System;using System.Collections.Generic;using System.IO;using System.Linq;+using System.Threading;using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Entities;using MediaBrowser.Controller.Library;@@ -9,7 +10,6 @@ using MediaBrowser.Model.Extensions;using MediaBrowser.Model.IO;using MediaBrowser.Model.System;using MediaBrowser.Model.Tasks;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace Emby.Server.Implementations.IO@@ -22,8 +22,7 @@ namespace Emby.Server.Implementations.IOprivate IServerConfigurationManager ConfigurationManager { get; set; }private readonly IFileSystem _fileSystem;private readonly List<string> _affectedPaths = new List<string>();- private ITimer _timer;- private readonly ITimerFactory _timerFactory;+ private Timer _timer;private readonly object _timerLock = new object();public string Path { get; private set; }@@ -31,7 +30,7 @@ namespace Emby.Server.Implementations.IOprivate readonly IEnvironmentInfo _environmentInfo;private readonly ILibraryManager _libraryManager;- public FileRefresher(string path, IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, ITaskManager taskManager, ILogger logger, ITimerFactory timerFactory, IEnvironmentInfo environmentInfo, ILibraryManager libraryManager1)+ public FileRefresher(string path, IFileSystem fileSystem, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, ITaskManager taskManager, ILogger logger, IEnvironmentInfo environmentInfo, ILibraryManager libraryManager1){logger.LogDebug("New file refresher created for {0}", path);Path = path;@@ -41,7 +40,6 @@ namespace Emby.Server.Implementations.IOLibraryManager = libraryManager;TaskManager = taskManager;Logger = logger;- _timerFactory = timerFactory;_environmentInfo = environmentInfo;_libraryManager = libraryManager1;AddPath(path);@@ -90,7 +88,7 @@ namespace Emby.Server.Implementations.IOif (_timer == null){- _timer = _timerFactory.Create(OnTimerCallback, null, TimeSpan.FromSeconds(ConfigurationManager.Configuration.LibraryMonitorDelay), TimeSpan.FromMilliseconds(-1));+ _timer = new Timer(OnTimerCallback, null, TimeSpan.FromSeconds(ConfigurationManager.Configuration.LibraryMonitorDelay), TimeSpan.FromMilliseconds(-1));}else{diff --git a/Emby.Server.Implementations/IO/LibraryMonitor.cs b/Emby.Server.Implementations/IO/LibraryMonitor.csindex 3a746ef603..11c684b128 100644--- a/Emby.Server.Implementations/IO/LibraryMonitor.cs+++ b/Emby.Server.Implementations/IO/LibraryMonitor.cs@@ -11,7 +11,6 @@ using MediaBrowser.Controller.Plugins;using MediaBrowser.Model.IO;using MediaBrowser.Model.System;using MediaBrowser.Model.Tasks;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace Emby.Server.Implementations.IO@@ -134,7 +133,6 @@ namespace Emby.Server.Implementations.IOprivate IServerConfigurationManager ConfigurationManager { get; set; }private readonly IFileSystem _fileSystem;- private readonly ITimerFactory _timerFactory;private readonly IEnvironmentInfo _environmentInfo;/// <summary>@@ -146,7 +144,6 @@ namespace Emby.Server.Implementations.IOILibraryManager libraryManager,IServerConfigurationManager configurationManager,IFileSystem fileSystem,- ITimerFactory timerFactory,IEnvironmentInfo environmentInfo){if (taskManager == null)@@ -159,7 +156,6 @@ namespace Emby.Server.Implementations.IOLogger = loggerFactory.CreateLogger(GetType().Name);ConfigurationManager = configurationManager;_fileSystem = fileSystem;- _timerFactory = timerFactory;_environmentInfo = environmentInfo;}@@ -545,7 +541,7 @@ namespace Emby.Server.Implementations.IO}}- var newRefresher = new FileRefresher(path, _fileSystem, ConfigurationManager, LibraryManager, TaskManager, Logger, _timerFactory, _environmentInfo, LibraryManager);+ var newRefresher = new FileRefresher(path, _fileSystem, ConfigurationManager, LibraryManager, TaskManager, Logger, _environmentInfo, LibraryManager);newRefresher.Completed += NewRefresher_Completed;_activeRefreshers.Add(newRefresher);}diff --git a/Emby.Server.Implementations/Library/MediaSourceManager.cs b/Emby.Server.Implementations/Library/MediaSourceManager.csindex 4f72651d49..24ab8e7619 100644--- a/Emby.Server.Implementations/Library/MediaSourceManager.cs+++ b/Emby.Server.Implementations/Library/MediaSourceManager.cs@@ -20,7 +20,6 @@ using MediaBrowser.Model.Globalization;using MediaBrowser.Model.IO;using MediaBrowser.Model.MediaInfo;using MediaBrowser.Model.Serialization;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace Emby.Server.Implementations.Library@@ -36,7 +35,6 @@ namespace Emby.Server.Implementations.Libraryprivate IMediaSourceProvider[] _providers;private readonly ILogger _logger;private readonly IUserDataManager _userDataManager;- private readonly ITimerFactory _timerFactory;private readonly Func<IMediaEncoder> _mediaEncoder;private ILocalizationManager _localizationManager;private IApplicationPaths _appPaths;@@ -51,7 +49,6 @@ namespace Emby.Server.Implementations.LibraryIJsonSerializer jsonSerializer,IFileSystem fileSystem,IUserDataManager userDataManager,- ITimerFactory timerFactory,Func<IMediaEncoder> mediaEncoder){_itemRepo = itemRepo;@@ -61,7 +58,6 @@ namespace Emby.Server.Implementations.Library_jsonSerializer = jsonSerializer;_fileSystem = fileSystem;_userDataManager = userDataManager;- _timerFactory = timerFactory;_mediaEncoder = mediaEncoder;_localizationManager = localizationManager;_appPaths = applicationPaths;diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.csindex b9a42a6ff7..84ca130b76 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs@@ -35,7 +35,6 @@ using MediaBrowser.Model.Providers;using MediaBrowser.Model.Querying;using MediaBrowser.Model.Reflection;using MediaBrowser.Model.Serialization;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace Emby.Server.Implementations.LiveTv.EmbyTV@@ -86,7 +85,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVILibraryMonitor libraryMonitor,IProviderManager providerManager,IMediaEncoder mediaEncoder,- ITimerFactory timerFactory,IProcessFactory processFactory){Current = this;@@ -108,7 +106,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV_streamHelper = streamHelper;_seriesTimerProvider = new SeriesTimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "seriestimers"));- _timerProvider = new TimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "timers"), _logger, timerFactory);+ _timerProvider = new TimerManager(fileSystem, jsonSerializer, _logger, Path.Combine(DataPath, "timers"), _logger);_timerProvider.TimerFired += _timerProvider_TimerFired;_config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated;diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.csindex 7f67d70a96..1dcb02f43e 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/TimerManager.cs@@ -2,29 +2,27 @@ using System;using System.Collections.Concurrent;using System.Globalization;using System.Linq;+using System.Threading;using MediaBrowser.Controller.LiveTv;using MediaBrowser.Model.Events;using MediaBrowser.Model.IO;using MediaBrowser.Model.LiveTv;using MediaBrowser.Model.Serialization;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace Emby.Server.Implementations.LiveTv.EmbyTV{public class TimerManager : ItemDataProvider<TimerInfo>{- private readonly ConcurrentDictionary<string, ITimer> _timers = new ConcurrentDictionary<string, ITimer>(StringComparer.OrdinalIgnoreCase);+ private readonly ConcurrentDictionary<string, Timer> _timers = new ConcurrentDictionary<string, Timer>(StringComparer.OrdinalIgnoreCase);private readonly ILogger _logger;public event EventHandler<GenericEventArgs<TimerInfo>> TimerFired;- private readonly ITimerFactory _timerFactory;- public TimerManager(IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, string dataPath, ILogger logger1, ITimerFactory timerFactory)+ public TimerManager(IFileSystem fileSystem, IJsonSerializer jsonSerializer, ILogger logger, string dataPath, ILogger logger1): base(fileSystem, jsonSerializer, logger, dataPath, (r1, r2) => string.Equals(r1.Id, r2.Id, StringComparison.OrdinalIgnoreCase)){_logger = logger1;- _timerFactory = timerFactory;}public void RestartTimers()@@ -125,7 +123,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVprivate void StartTimer(TimerInfo item, TimeSpan dueTime){- var timer = _timerFactory.Create(TimerCallback, item.Id, dueTime, TimeSpan.Zero);+ var timer = new Timer(TimerCallback, item.Id, dueTime, TimeSpan.Zero);if (_timers.TryAdd(item.Id, timer)){diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.csindex b03345e03c..fa0ab62d32 100644--- a/Emby.Server.Implementations/Session/SessionManager.cs+++ b/Emby.Server.Implementations/Session/SessionManager.cs@@ -27,7 +27,6 @@ using MediaBrowser.Model.Library;using MediaBrowser.Model.Querying;using MediaBrowser.Model.Serialization;using MediaBrowser.Model.Session;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace Emby.Server.Implementations.Session@@ -60,7 +59,6 @@ namespace Emby.Server.Implementations.Sessionprivate readonly IAuthenticationRepository _authRepo;private readonly IDeviceManager _deviceManager;- private readonly ITimerFactory _timerFactory;/// <summary>/// The _active connections@@ -103,8 +101,7 @@ namespace Emby.Server.Implementations.SessionIHttpClient httpClient,IAuthenticationRepository authRepo,IDeviceManager deviceManager,- IMediaSourceManager mediaSourceManager,- ITimerFactory timerFactory)+ IMediaSourceManager mediaSourceManager){_userDataManager = userDataManager;_logger = loggerFactory.CreateLogger(nameof(SessionManager));@@ -119,7 +116,6 @@ namespace Emby.Server.Implementations.Session_authRepo = authRepo;_deviceManager = deviceManager;_mediaSourceManager = mediaSourceManager;- _timerFactory = timerFactory;_deviceManager.DeviceOptionsUpdated += _deviceManager_DeviceOptionsUpdated;}@@ -503,13 +499,13 @@ namespace Emby.Server.Implementations.Sessionreturn users;}- private ITimer _idleTimer;+ private Timer _idleTimer;private void StartIdleCheckTimer(){if (_idleTimer == null){- _idleTimer = _timerFactory.Create(CheckForIdlePlayback, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5));+ _idleTimer = new Timer(CheckForIdlePlayback, null, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(5));}}private void StopIdleCheckTimer()@@ -606,7 +602,7 @@ namespace Emby.Server.Implementations.SessionClearTranscodingInfo(session.DeviceId);}- session.StartAutomaticProgress(_timerFactory, info);+ session.StartAutomaticProgress(info);var users = GetUsers(session);@@ -717,7 +713,7 @@ namespace Emby.Server.Implementations.Sessionif (!isAutomated){- session.StartAutomaticProgress(_timerFactory, info);+ session.StartAutomaticProgress(info);}StartIdleCheckTimer();diff --git a/Emby.Server.Implementations/Threading/CommonTimer.cs b/Emby.Server.Implementations/Threading/CommonTimer.csdeleted file mode 100644index 5a05da564f..0000000000--- a/Emby.Server.Implementations/Threading/CommonTimer.cs+++ /dev/null@@ -1,36 +0,0 @@-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<object> callback, object state, TimeSpan dueTime, TimeSpan period)- {- _timer = new Timer(new TimerCallback(callback), state, dueTime, period);- }-- public CommonTimer(Action<object> 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.csdeleted file mode 100644index ca50064c7a..0000000000--- a/Emby.Server.Implementations/Threading/TimerFactory.cs+++ /dev/null@@ -1,18 +0,0 @@-using System;-using MediaBrowser.Model.Threading;--namespace Emby.Server.Implementations.Threading-{- public class TimerFactory : ITimerFactory- {- public ITimer Create(Action<object> callback, object state, TimeSpan dueTime, TimeSpan period)- {- return new CommonTimer(callback, state, dueTime, period);- }-- public ITimer Create(Action<object> callback, object state, int dueTimeMs, int periodMs)- {- return new CommonTimer(callback, state, dueTimeMs, periodMs);- }- }-}diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.csindex c1f753190c..8dbc26356d 100644--- a/MediaBrowser.Api/ApiEntryPoint.cs+++ b/MediaBrowser.Api/ApiEntryPoint.cs@@ -18,7 +18,6 @@ using MediaBrowser.Model.Diagnostics;using MediaBrowser.Model.Dto;using MediaBrowser.Model.IO;using MediaBrowser.Model.Session;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace MediaBrowser.Api@@ -48,7 +47,6 @@ namespace MediaBrowser.Apiprivate readonly ISessionManager _sessionManager;private readonly IFileSystem _fileSystem;private readonly IMediaSourceManager _mediaSourceManager;- public readonly ITimerFactory TimerFactory;public readonly IProcessFactory ProcessFactory;/// <summary>@@ -75,7 +73,6 @@ namespace MediaBrowser.ApiIServerConfigurationManager config,IFileSystem fileSystem,IMediaSourceManager mediaSourceManager,- ITimerFactory timerFactory,IProcessFactory processFactory,IHttpResultFactory resultFactory){@@ -84,7 +81,6 @@ namespace MediaBrowser.Api_config = config;_fileSystem = fileSystem;_mediaSourceManager = mediaSourceManager;- TimerFactory = timerFactory;ProcessFactory = processFactory;ResultFactory = resultFactory;@@ -260,7 +256,7 @@ namespace MediaBrowser.Api{lock (_activeTranscodingJobs){- var job = new TranscodingJob(Logger, TimerFactory)+ var job = new TranscodingJob(Logger){Type = type,Path = path,@@ -765,9 +761,7 @@ namespace MediaBrowser.Api/// Gets or sets the kill timer./// </summary>/// <value>The kill timer.</value>- private ITimer KillTimer { get; set; }-- private readonly ITimerFactory _timerFactory;+ private Timer KillTimer { get; set; }public string DeviceId { get; set; }@@ -797,10 +791,9 @@ namespace MediaBrowser.Apipublic DateTime LastPingDate { get; set; }public int PingTimeout { get; set; }- public TranscodingJob(ILogger logger, ITimerFactory timerFactory)+ public TranscodingJob(ILogger logger){Logger = logger;- _timerFactory = timerFactory;}public void StopKillTimer()@@ -843,7 +836,7 @@ namespace MediaBrowser.Apiif (KillTimer == null){//Logger.LogDebug("Starting kill timer at {0}ms. JobId {1} PlaySessionId {2}", intervalMs, Id, PlaySessionId);- KillTimer = _timerFactory.Create(callback, this, intervalMs, Timeout.Infinite);+ KillTimer = new Timer(new TimerCallback(callback), this, intervalMs, Timeout.Infinite);}else{diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.csindex 641d539f2b..0736862989 100644--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs@@ -336,7 +336,7 @@ namespace MediaBrowser.Api.Playback{if (EnableThrottling(state)){- transcodingJob.TranscodingThrottler = state.TranscodingThrottler = new TranscodingThrottler(transcodingJob, Logger, ServerConfigurationManager, ApiEntryPoint.Instance.TimerFactory, FileSystem);+ transcodingJob.TranscodingThrottler = state.TranscodingThrottler = new TranscodingThrottler(transcodingJob, Logger, ServerConfigurationManager, FileSystem);state.TranscodingThrottler.Start();}}diff --git a/MediaBrowser.Api/Playback/TranscodingThrottler.cs b/MediaBrowser.Api/Playback/TranscodingThrottler.csindex 9f416098af..0e73d77efd 100644--- a/MediaBrowser.Api/Playback/TranscodingThrottler.cs+++ b/MediaBrowser.Api/Playback/TranscodingThrottler.cs@@ -1,9 +1,9 @@using System;+using System.Threading;using System.Threading.Tasks;using MediaBrowser.Common.Configuration;using MediaBrowser.Model.Configuration;using MediaBrowser.Model.IO;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace MediaBrowser.Api.Playback@@ -12,18 +12,16 @@ namespace MediaBrowser.Api.Playback{private readonly TranscodingJob _job;private readonly ILogger _logger;- private ITimer _timer;+ private Timer _timer;private bool _isPaused;private readonly IConfigurationManager _config;- private readonly ITimerFactory _timerFactory;private readonly IFileSystem _fileSystem;- public TranscodingThrottler(TranscodingJob job, ILogger logger, IConfigurationManager config, ITimerFactory timerFactory, IFileSystem fileSystem)+ public TranscodingThrottler(TranscodingJob job, ILogger logger, IConfigurationManager config, IFileSystem fileSystem){_job = job;_logger = logger;_config = config;- _timerFactory = timerFactory;_fileSystem = fileSystem;}@@ -34,7 +32,7 @@ namespace MediaBrowser.Api.Playbackpublic void Start(){- _timer = _timerFactory.Create(TimerCallback, null, 5000, 5000);+ _timer = new Timer(TimerCallback, null, 5000, 5000);}private async void TimerCallback(object state)diff --git a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.csindex 4e7e1c8ed2..4242a00e21 100644--- a/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs+++ b/MediaBrowser.Controller/Net/BasePeriodicWebSocketListener.cs@@ -6,7 +6,6 @@ using System.Net.WebSockets;using System.Threading;using System.Threading.Tasks;using MediaBrowser.Model.Net;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace MediaBrowser.Controller.Net@@ -23,8 +22,8 @@ namespace MediaBrowser.Controller.Net/// <summary>/// The _active connections/// </summary>- protected readonly List<Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType>> ActiveConnections =- new List<Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType>>();+ protected readonly List<Tuple<IWebSocketConnection, CancellationTokenSource, Timer, TStateType>> ActiveConnections =+ new List<Tuple<IWebSocketConnection, CancellationTokenSource, Timer, TStateType>>();/// <summary>/// Gets the name.@@ -44,8 +43,6 @@ namespace MediaBrowser.Controller.Net/// </summary>protected ILogger Logger;- protected ITimerFactory TimerFactory { get; private set; }-protected BasePeriodicWebSocketListener(ILogger logger){if (logger == null)@@ -111,7 +108,7 @@ namespace MediaBrowser.Controller.NetLogger.LogDebug("{1} Begin transmitting over websocket to {0}", message.Connection.RemoteEndPoint, GetType().Name);var timer = SendOnTimer ?- TimerFactory.Create(TimerCallback, message.Connection, Timeout.Infinite, Timeout.Infinite) :+ new Timer(TimerCallback, message.Connection, Timeout.Infinite, Timeout.Infinite) :null;var state = new TStateType@@ -122,7 +119,7 @@ namespace MediaBrowser.Controller.Netlock (ActiveConnections){- ActiveConnections.Add(new Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType>(message.Connection, cancellationTokenSource, timer, state));+ ActiveConnections.Add(new Tuple<IWebSocketConnection, CancellationTokenSource, Timer, TStateType>(message.Connection, cancellationTokenSource, timer, state));}if (timer != null)@@ -139,7 +136,7 @@ namespace MediaBrowser.Controller.Net{var connection = (IWebSocketConnection)state;- Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType> tuple;+ Tuple<IWebSocketConnection, CancellationTokenSource, Timer, TStateType> tuple;lock (ActiveConnections){@@ -162,7 +159,7 @@ namespace MediaBrowser.Controller.Netprotected void SendData(bool force){- Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType>[] tuples;+ Tuple<IWebSocketConnection, CancellationTokenSource, Timer, TStateType>[] tuples;lock (ActiveConnections){@@ -190,7 +187,7 @@ namespace MediaBrowser.Controller.Net}}- private async void SendData(Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType> tuple)+ private async void SendData(Tuple<IWebSocketConnection, CancellationTokenSource, Timer, TStateType> tuple){var connection = tuple.Item1;@@ -249,7 +246,7 @@ namespace MediaBrowser.Controller.Net/// Disposes the connection./// </summary>/// <param name="connection">The connection.</param>- private void DisposeConnection(Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType> connection)+ private void DisposeConnection(Tuple<IWebSocketConnection, CancellationTokenSource, Timer, TStateType> connection){Logger.LogDebug("{1} stop transmitting over websocket to {0}", connection.Item1.RemoteEndPoint, GetType().Name);diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.csindex d698795dd3..f0e81e8e7a 100644--- a/MediaBrowser.Controller/Session/SessionInfo.cs+++ b/MediaBrowser.Controller/Session/SessionInfo.cs@@ -1,10 +1,10 @@using System;using System.Linq;+using System.Threading;using MediaBrowser.Controller.Entities;using MediaBrowser.Model.Dto;using MediaBrowser.Model.Serialization;using MediaBrowser.Model.Session;-using MediaBrowser.Model.Threading;using Microsoft.Extensions.Logging;namespace MediaBrowser.Controller.Session@@ -268,10 +268,10 @@ namespace MediaBrowser.Controller.Session}private readonly object _progressLock = new object();- private ITimer _progressTimer;+ private Timer _progressTimer;private PlaybackProgressInfo _lastProgressInfo;- public void StartAutomaticProgress(ITimerFactory timerFactory, PlaybackProgressInfo progressInfo)+ public void StartAutomaticProgress(PlaybackProgressInfo progressInfo){if (_disposed){@@ -284,7 +284,7 @@ namespace MediaBrowser.Controller.Sessionif (_progressTimer == null){- _progressTimer = timerFactory.Create(OnProgressTimerCallback, null, 1000, 1000);+ _progressTimer = new Timer(OnProgressTimerCallback, null, 1000, 1000);}else{diff --git a/MediaBrowser.Model/Threading/ITimer.cs b/MediaBrowser.Model/Threading/ITimer.csdeleted file mode 100644index 2bec222665..0000000000--- a/MediaBrowser.Model/Threading/ITimer.cs+++ /dev/null@@ -1,10 +0,0 @@-using System;--namespace MediaBrowser.Model.Threading-{- public interface ITimer : IDisposable- {- void Change(TimeSpan dueTime, TimeSpan period);- void Change(int dueTimeMs, int periodMs);- }-}diff --git a/MediaBrowser.Model/Threading/ITimerFactory.cs b/MediaBrowser.Model/Threading/ITimerFactory.csdeleted file mode 100644index 1161958a4b..0000000000--- a/MediaBrowser.Model/Threading/ITimerFactory.cs+++ /dev/null@@ -1,10 +0,0 @@-using System;--namespace MediaBrowser.Model.Threading-{- public interface ITimerFactory- {- ITimer Create(Action<object> callback, object state, TimeSpan dueTime, TimeSpan period);- ITimer Create(Action<object> callback, object state, int dueTimeMs, int periodMs);- }-}diff --git a/RSSDP/SsdpDeviceLocator.cs b/RSSDP/SsdpDeviceLocator.csindex 1348cce8da..128bdfcbb4 100644--- a/RSSDP/SsdpDeviceLocator.cs+++ b/RSSDP/SsdpDeviceLocator.cs@@ -8,7 +8,6 @@ using System.Text;using System.Threading;using System.Threading.Tasks;using MediaBrowser.Model.Net;-using MediaBrowser.Model.Threading;namespace Rssdp.Infrastructure{@@ -23,8 +22,7 @@ namespace Rssdp.Infrastructureprivate List<DiscoveredSsdpDevice> _Devices;private ISsdpCommunicationsServer _CommunicationsServer;- private ITimer _BroadcastTimer;- private ITimerFactory _timerFactory;+ private Timer _BroadcastTimer;private object _timerLock = new object();private readonly TimeSpan DefaultSearchWaitTime = TimeSpan.FromSeconds(4);@@ -37,12 +35,11 @@ namespace Rssdp.Infrastructure/// <summary>/// Default constructor./// </summary>- public SsdpDeviceLocator(ISsdpCommunicationsServer communicationsServer, ITimerFactory timerFactory)+ public SsdpDeviceLocator(ISsdpCommunicationsServer communicationsServer){if (communicationsServer == null) throw new ArgumentNullException(nameof(communicationsServer));_CommunicationsServer = communicationsServer;- _timerFactory = timerFactory;_CommunicationsServer.ResponseReceived += CommsServer_ResponseReceived;_Devices = new List<DiscoveredSsdpDevice>();@@ -94,7 +91,7 @@ namespace Rssdp.Infrastructure{if (_BroadcastTimer == null){- _BroadcastTimer = _timerFactory.Create(OnBroadcastTimerCallback, null, dueTime, period);+ _BroadcastTimer = new Timer(OnBroadcastTimerCallback, null, dueTime, period);}else{diff --git a/RSSDP/SsdpDevicePublisher.cs b/RSSDP/SsdpDevicePublisher.csindex 8a73e6a2d3..ce64ba1176 100644--- a/RSSDP/SsdpDevicePublisher.cs+++ b/RSSDP/SsdpDevicePublisher.cs@@ -7,7 +7,6 @@ using System.Text;using System.Threading;using System.Threading.Tasks;using MediaBrowser.Model.Net;-using MediaBrowser.Model.Threading;using Rssdp;namespace Rssdp.Infrastructure@@ -27,8 +26,7 @@ namespace Rssdp.Infrastructureprivate IList<SsdpRootDevice> _Devices;private IReadOnlyList<SsdpRootDevice> _ReadOnlyDevices;- private ITimer _RebroadcastAliveNotificationsTimer;- private ITimerFactory _timerFactory;+ private Timer _RebroadcastAliveNotificationsTimer;private IDictionary<string, SearchRequest> _RecentSearchRequests;@@ -39,7 +37,7 @@ namespace Rssdp.Infrastructure/// <summary>/// Default constructor./// </summary>- public SsdpDevicePublisher(ISsdpCommunicationsServer communicationsServer, ITimerFactory timerFactory, string osName, string osVersion)+ public SsdpDevicePublisher(ISsdpCommunicationsServer communicationsServer, string osName, string osVersion){if (communicationsServer == null) throw new ArgumentNullException(nameof(communicationsServer));if (osName == null) throw new ArgumentNullException(nameof(osName));@@ -48,7 +46,6 @@ namespace Rssdp.Infrastructureif (osVersion.Length == 0) throw new ArgumentException("osVersion cannot be an empty string.", nameof(osName));_SupportPnpRootDevice = true;- _timerFactory = timerFactory;_Devices = new List<SsdpRootDevice>();_ReadOnlyDevices = new ReadOnlyCollection<SsdpRootDevice>(_Devices);_RecentSearchRequests = new Dictionary<string, SearchRequest>(StringComparer.OrdinalIgnoreCase);@@ -64,7 +61,7 @@ namespace Rssdp.Infrastructurepublic void StartBroadcastingAliveMessages(TimeSpan interval){- _RebroadcastAliveNotificationsTimer = _timerFactory.Create(SendAllAliveNotifications, null, TimeSpan.FromSeconds(5), interval);+ _RebroadcastAliveNotificationsTimer = new Timer(SendAllAliveNotifications, null, TimeSpan.FromSeconds(5), interval);}/// <summary>