예제 #1
0
        private async Task BackgroundCleanup(ICacheStack cacheStack)
        {
            var cancellationToken = TokenSource.Token;

            while (!cancellationToken.IsCancellationRequested)
            {
                await Task.Delay(Frequency, cancellationToken);

                cancellationToken.ThrowIfCancellationRequested();
                await cacheStack.CleanupAsync();
            }
        }
예제 #2
0
        private async Task BackgroundCleanup(ICacheStack cacheStack)
        {
            try
            {
                var cancellationToken = TokenSource.Token;
                while (!cancellationToken.IsCancellationRequested)
                {
                    await Task.Delay(Frequency, cancellationToken);

                    cancellationToken.ThrowIfCancellationRequested();
                    await cacheStack.CleanupAsync();
                }
            }
            catch (Exception ex) when(ex is TaskCanceledException || ex is OperationCanceledException)
            {
            }
        }