mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 11:34:57 +02:00
Properly remove event handler
This commit is contained in:
parent
558baeac48
commit
210af0e73e
1 changed files with 10 additions and 6 deletions
|
@ -65,23 +65,20 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||||
.ToString();
|
.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void OnConfigurationUpdated(object sender, EventArgs e)
|
private void OnConfigurationUpdated(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (!string.Equals(_lastConfigIdentifier, GetConfigIdentifier(), StringComparison.OrdinalIgnoreCase))
|
if (!string.Equals(_lastConfigIdentifier, GetConfigIdentifier(), StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
await RunAsync().ConfigureAwait(false);
|
Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public Task RunAsync()
|
public Task RunAsync()
|
||||||
{
|
{
|
||||||
if (_config.Configuration.EnableUPnP && _config.Configuration.EnableRemoteAccess)
|
Start();
|
||||||
{
|
|
||||||
Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
_config.ConfigurationUpdated += OnConfigurationUpdated;
|
_config.ConfigurationUpdated += OnConfigurationUpdated;
|
||||||
|
|
||||||
|
@ -90,6 +87,11 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
if (!_config.Configuration.EnableUPnP || !_config.Configuration.EnableRemoteAccess)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_logger.LogDebug("Starting NAT discovery");
|
_logger.LogDebug("Starting NAT discovery");
|
||||||
|
|
||||||
NatUtility.DeviceFound += OnNatUtilityDeviceFound;
|
NatUtility.DeviceFound += OnNatUtilityDeviceFound;
|
||||||
|
@ -214,6 +216,8 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_config.ConfigurationUpdated -= OnConfigurationUpdated;
|
||||||
|
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
_timer = null;
|
_timer = null;
|
||||||
|
|
Loading…
Reference in a new issue