Improved dispose method

This commit is contained in:
Bond-009 2019-03-25 17:32:27 +01:00
parent fc8de8aead
commit d623f616fa

View File

@ -607,22 +607,34 @@ namespace Emby.Dlna.PlayTo
public void Dispose()
{
if (!_disposed)
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
_disposed = true;
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;
_deviceDiscovery.DeviceLeft -= _deviceDiscovery_DeviceLeft;
_device.OnDeviceUnavailable = null;
_device = null;
_device.Dispose();
}
_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)
{