diff options
| author | adrez99 <59739805+adrez99@users.noreply.github.com> | 2022-08-04 17:22:35 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-04 17:22:35 +0200 |
| commit | b8afdd892af01fd99011a6dc3df65cfb762084d6 (patch) | |
| tree | 2ed657a192769b8deda54c9c20998eeeabbdca78 /MediaBrowser.Controller/Session | |
| parent | aadd8ee97135bec44ad3e09a78a1bf0523149ccf (diff) | |
| parent | 63d943aab92a4b5f69e625a269eb830bcbfb4d22 (diff) | |
Merge branch 'master' into gzip
Diffstat (limited to 'MediaBrowser.Controller/Session')
| -rw-r--r-- | MediaBrowser.Controller/Session/SessionInfo.cs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index c2ca233868..b4520ae48f 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Linq; using System.Text.Json.Serialization; using System.Threading; +using System.Threading.Tasks; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Session; @@ -17,7 +18,7 @@ namespace MediaBrowser.Controller.Session /// <summary> /// Class SessionInfo. /// </summary> - public sealed class SessionInfo : IDisposable + public sealed class SessionInfo : IAsyncDisposable, IDisposable { // 1 second private const long ProgressIncrement = 10000000; @@ -380,10 +381,28 @@ namespace MediaBrowser.Controller.Session { if (controller is IDisposable disposable) { - _logger.LogDebug("Disposing session controller {0}", disposable.GetType().Name); + _logger.LogDebug("Disposing session controller synchronously {TypeName}", disposable.GetType().Name); disposable.Dispose(); } } } + + public async ValueTask DisposeAsync() + { + _disposed = true; + + StopAutomaticProgress(); + + var controllers = SessionControllers.ToList(); + + foreach (var controller in controllers) + { + if (controller is IAsyncDisposable disposableAsync) + { + _logger.LogDebug("Disposing session controller asynchronously {TypeName}", disposableAsync.GetType().Name); + await disposableAsync.DisposeAsync().ConfigureAwait(false); + } + } + } } } |
