mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-17 15:46:22 +00:00
Properly remove event handler
This commit is contained in:
@@ -65,23 +65,20 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
.ToString();
|
||||
}
|
||||
|
||||
private async void OnConfigurationUpdated(object sender, EventArgs e)
|
||||
private void OnConfigurationUpdated(object sender, EventArgs e)
|
||||
{
|
||||
if (!string.Equals(_lastConfigIdentifier, GetConfigIdentifier(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Stop();
|
||||
|
||||
await RunAsync().ConfigureAwait(false);
|
||||
Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task RunAsync()
|
||||
{
|
||||
if (_config.Configuration.EnableUPnP && _config.Configuration.EnableRemoteAccess)
|
||||
{
|
||||
Start();
|
||||
}
|
||||
Start();
|
||||
|
||||
_config.ConfigurationUpdated += OnConfigurationUpdated;
|
||||
|
||||
@@ -90,6 +87,11 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (!_config.Configuration.EnableUPnP || !_config.Configuration.EnableRemoteAccess)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogDebug("Starting NAT discovery");
|
||||
|
||||
NatUtility.DeviceFound += OnNatUtilityDeviceFound;
|
||||
@@ -214,6 +216,8 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||
return;
|
||||
}
|
||||
|
||||
_config.ConfigurationUpdated -= OnConfigurationUpdated;
|
||||
|
||||
Stop();
|
||||
|
||||
_timer = null;
|
||||
|
||||
Reference in New Issue
Block a user