aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-03-25 17:32:27 +0100
committerBond-009 <bond.009@outlook.com>2019-03-25 17:32:27 +0100
commitd623f616fa01abf5c0d0625eaf5c17c4acf86803 (patch)
tree139f92fc80610d3b4c565d68140d22629e0e484e
parentfc8de8aeadaa74b691ec909f9481da9a6d90fd2e (diff)
Improved dispose method
-rw-r--r--Emby.Dlna/PlayTo/PlayToController.cs32
1 files changed, 22 insertions, 10 deletions
diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.cs
index 0808c77d1..c58f16438 100644
--- a/Emby.Dlna/PlayTo/PlayToController.cs
+++ b/Emby.Dlna/PlayTo/PlayToController.cs
@@ -607,22 +607,34 @@ namespace Emby.Dlna.PlayTo
public void Dispose()
{
- if (!_disposed)
- {
- _disposed = true;
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
- _device.PlaybackStart -= _device_PlaybackStart;
- _device.PlaybackProgress -= _device_PlaybackProgress;
- _device.PlaybackStopped -= _device_PlaybackStopped;
- _device.MediaChanged -= _device_MediaChanged;
- //_deviceDiscovery.DeviceLeft -= _deviceDiscovery_DeviceLeft;
- _device.OnDeviceUnavailable = null;
+ protected virtual void Dispose(bool disposing)
+ {
+ if (_disposed)
+ {
+ return;
+ }
+ if (disposing)
+ {
_device.Dispose();
}
+
+ _device.PlaybackStart -= _device_PlaybackStart;
+ _device.PlaybackProgress -= _device_PlaybackProgress;
+ _device.PlaybackStopped -= _device_PlaybackStopped;
+ _device.MediaChanged -= _device_MediaChanged;
+ _deviceDiscovery.DeviceLeft -= _deviceDiscovery_DeviceLeft;
+ _device.OnDeviceUnavailable = null;
+ _device = null;
+
+ _disposed = true;
}
- private readonly CultureInfo _usCulture = new CultureInfo("en-US");
+ private static readonly CultureInfo _usCulture = CultureInfo.ReadOnly(new CultureInfo("en-US"));
private Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken)
{