move the Dispose logic into DisposeAsyncCore

pull/7732/head
Luke Brown 2 years ago
parent 3e8fe1ce11
commit 0f7ba42987

@ -1234,7 +1234,7 @@ namespace Emby.Server.Implementations
public async ValueTask DisposeAsync()
{
await DisposeAsyncCore().ConfigureAwait(false);
Dispose(true);
Dispose(false);
GC.SuppressFinalize(this);
}
@ -1244,6 +1244,31 @@ namespace Emby.Server.Implementations
/// <returns>A ValueTask.</returns>
protected virtual async ValueTask DisposeAsyncCore()
{
var type = GetType();
Logger.LogInformation("Disposing {Type}", type.Name);
foreach (var (part, _) in _disposableParts)
{
var partType = part.GetType();
if (partType == type)
{
continue;
}
Logger.LogInformation("Disposing {Type}", partType.Name);
try
{
part.Dispose();
}
catch (Exception ex)
{
Logger.LogError(ex, "Error disposing {Type}", partType.Name);
}
}
// used for closing websockets
foreach (var session in _sessionManager.Sessions)
{
await session.DisposeAsync().ConfigureAwait(false);

Loading…
Cancel
Save