From 586caab7c4783a78c86f64c6d3edef08c5b07442 Mon Sep 17 00:00:00 2001 From: icylogic Date: Tue, 19 Jan 2016 02:04:49 +0800 Subject: [PATCH] follow CA1001: Types that own disposable fields should be disposable https://msdn.microsoft.com/library/ms182172.aspx --- .../Controller/Service/AvailabilityStatistics.cs | 9 ++++++++- .../Controller/Strategy/StatisticsStrategy.cs | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs b/shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs index 6a41210a..0a67962c 100644 --- a/shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs +++ b/shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs @@ -16,7 +16,7 @@ namespace Shadowsocks.Controller { using Statistics = Dictionary>; - public sealed class AvailabilityStatistics + public sealed class AvailabilityStatistics : IDisposable { public const string DateTimePattern = "yyyy-MM-dd HH:mm:ss"; private const string StatisticsFilesName = "shadowsocks.availability.json"; @@ -342,5 +342,12 @@ namespace Shadowsocks.Controller Server = server; } } + + public void Dispose() + { + _recorder.Dispose(); + _writer.Dispose(); + _speedMonior.Dispose(); + } } } \ No newline at end of file diff --git a/shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs b/shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs index 3567291e..d9d786d2 100644 --- a/shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs +++ b/shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs @@ -12,7 +12,8 @@ using Shadowsocks.Model; namespace Shadowsocks.Controller.Strategy { using Statistics = Dictionary>; - class StatisticsStrategy : IStrategy + + internal class StatisticsStrategy : IStrategy, IDisposable { private readonly ShadowsocksController _controller; private Server _currentServer; @@ -152,5 +153,10 @@ namespace Shadowsocks.Controller.Strategy { //TODO: combine this part of data with ICMP statics } + + public void Dispose() + { + _timer.Dispose(); + } } }