Просмотр исходного кода

Fix disposable analyzer issues in ExternalPortForwarding

Patrick Barron 1 год назад
Родитель
Сommit
612edaed7a
1 измененных файлов с 3 добавлено и 12 удалено
  1. 3 12
      Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs

+ 3 - 12
Emby.Server.Implementations/EntryPoints/ExternalPortForwarding.cs

@@ -21,7 +21,7 @@ namespace Emby.Server.Implementations.EntryPoints
     /// <summary>
     /// <summary>
     /// Server entrypoint handling external port forwarding.
     /// Server entrypoint handling external port forwarding.
     /// </summary>
     /// </summary>
-    public class ExternalPortForwarding : IServerEntryPoint
+    public sealed class ExternalPortForwarding : IServerEntryPoint
     {
     {
         private readonly IServerApplicationHost _appHost;
         private readonly IServerApplicationHost _appHost;
         private readonly ILogger<ExternalPortForwarding> _logger;
         private readonly ILogger<ExternalPortForwarding> _logger;
@@ -32,7 +32,7 @@ namespace Emby.Server.Implementations.EntryPoints
         private Timer _timer;
         private Timer _timer;
         private string _configIdentifier;
         private string _configIdentifier;
 
 
-        private bool _disposed = false;
+        private bool _disposed;
 
 
         /// <summary>
         /// <summary>
         /// Initializes a new instance of the <see cref="ExternalPortForwarding"/> class.
         /// Initializes a new instance of the <see cref="ExternalPortForwarding"/> class.
@@ -177,16 +177,6 @@ namespace Emby.Server.Implementations.EntryPoints
 
 
         /// <inheritdoc />
         /// <inheritdoc />
         public void Dispose()
         public void Dispose()
-        {
-            Dispose(true);
-            GC.SuppressFinalize(this);
-        }
-
-        /// <summary>
-        /// Releases unmanaged and - optionally - managed resources.
-        /// </summary>
-        /// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
-        protected virtual void Dispose(bool dispose)
         {
         {
             if (_disposed)
             if (_disposed)
             {
             {
@@ -197,6 +187,7 @@ namespace Emby.Server.Implementations.EntryPoints
 
 
             Stop();
             Stop();
 
 
+            _timer?.Dispose();
             _timer = null;
             _timer = null;
 
 
             _disposed = true;
             _disposed = true;