diff --git a/src/DicomWebClient/CLI/Stow.cs b/src/DicomWebClient/CLI/Stow.cs index 460b5d9e7..509abef66 100644 --- a/src/DicomWebClient/CLI/Stow.cs +++ b/src/DicomWebClient/CLI/Stow.cs @@ -29,7 +29,7 @@ namespace Monai.Deploy.InformaticsGateway.DicomWeb.Client.CLI { [Command("stow", "Use stow to store DICOM instances to a remote DICOMweb server.")] - public class Stow : ConsoleAppBase + public class Stow : ConsoleAppBase, IDisposable { private readonly IDicomWebClient _dicomWebClient; private readonly ILogger _logger; @@ -138,5 +138,10 @@ private void ValidateOptions(string rootUrl, out Uri rootUri) rootUri = new Uri(rootUrl); rootUri = rootUri.EnsureUriEndsWithSlash(); } + + public void Dispose() + { + _cancellationTokeSource.Dispose(); + } } } diff --git a/src/InformaticsGateway/Services/Connectors/PayloadNotificationService.cs b/src/InformaticsGateway/Services/Connectors/PayloadNotificationService.cs index 45bc68268..e783faeaf 100755 --- a/src/InformaticsGateway/Services/Connectors/PayloadNotificationService.cs +++ b/src/InformaticsGateway/Services/Connectors/PayloadNotificationService.cs @@ -321,6 +321,7 @@ protected virtual void Dispose(bool disposing) { if (disposing) { + _cancellationTokenSource.Dispose(); _scope.Dispose(); } diff --git a/src/InformaticsGateway/Services/Scu/ScuService.cs b/src/InformaticsGateway/Services/Scu/ScuService.cs index 1833955d7..4326d0535 100755 --- a/src/InformaticsGateway/Services/Scu/ScuService.cs +++ b/src/InformaticsGateway/Services/Scu/ScuService.cs @@ -65,7 +65,7 @@ private Task BackgroundProcessing(CancellationToken cancellationToken) { var item = _workQueue.Dequeue(cancellationToken); - var linkedCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, item.CancellationToken); + using var linkedCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, item.CancellationToken); ProcessThread(item, linkedCancellationToken.Token); } diff --git a/src/InformaticsGateway/Services/Storage/ObjectUploadService.cs b/src/InformaticsGateway/Services/Storage/ObjectUploadService.cs index 49d894728..fbbaffd7b 100755 --- a/src/InformaticsGateway/Services/Storage/ObjectUploadService.cs +++ b/src/InformaticsGateway/Services/Storage/ObjectUploadService.cs @@ -213,7 +213,7 @@ private async Task VerifyExists(string path, CancellationToken cancellatio }) .ExecuteAsync(async () => { - var internalCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + using var internalCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); internalCancellationTokenSource.CancelAfter(_configuration.Value.Storage.StorageServiceListTimeout); var exists = await _storageService.VerifyObjectExistsAsync(_configuration.Value.Storage.StorageServiceBucketName, path).ConfigureAwait(false); _logger.VerifyFileExists(path, exists); @@ -268,6 +268,7 @@ protected virtual void Dispose(bool disposing) { if (disposing) { + _cancellationTokenSource.Dispose(); _scope.Dispose(); }