The Free Software Media System - Server Backend & API
Improved dispose method
Bond-009d623f616fa01
diff --git a/Emby.Dlna/PlayTo/PlayToController.cs b/Emby.Dlna/PlayTo/PlayToController.csindex 0808c77d11..c58f16438b 100644--- a/Emby.Dlna/PlayTo/PlayToController.cs+++ b/Emby.Dlna/PlayTo/PlayToController.cs@@ -607,22 +607,34 @@ namespace Emby.Dlna.PlayTopublic 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){