Added playing song view. Adding styling to playing song. Fixed caching cancellation issue.

This commit is contained in:
2025-04-03 21:45:13 -04:00
parent 2b2cb9d942
commit f459e0e6e6
13 changed files with 344 additions and 33 deletions

View File

@@ -32,30 +32,39 @@ public abstract class Cache<TKey, TValue> : ICache<TKey, TValue> where TKey : no
SemaphoreSlim lockObject = _locks.GetOrAdd(actualKey, (key) => new SemaphoreSlim(1, 1));
bool throttlerAcquired = false;
bool lockAcquired = false;
try
{
await _throttler.WaitAsync(cancellationToken);
throttlerAcquired = true;
if (cancellationToken.IsCancellationRequested)
return default;
await lockObject.WaitAsync(cancellationToken);
lockAcquired = true;
if (cancellationToken.IsCancellationRequested)
return default;
return TryGetValue(actualKey) ?? await FetchAsync2(key, cancellationToken);
}
catch (OperationCanceledException)
{
return default;
}
finally
{
lockObject.Release();
if (lockAcquired)
lockObject.Release();
_locks.TryRemove(lockObject, out _);
_throttler.Release();
if (throttlerAcquired)
_throttler.Release();
}
//return TryGetValue(actualKey) ?? Refresh(key);
}
private async Task<TValue?> FetchAsync2(TKey key, CancellationToken cancellationToken)