internal override async Task RegisterCache(bool async, ITokenCache tokenCache, CancellationToken cancellationToken) { MsalCacheHelperWrapper cacheHelper = await GetCacheHelperAsync(async, cancellationToken).ConfigureAwait(false); cacheHelper.RegisterCache(tokenCache); await base.RegisterCache(async, tokenCache, cancellationToken).ConfigureAwait(false); }
internal virtual async Task RegisterCache(bool async, ITokenCache tokenCache, CancellationToken cancellationToken) { if (_persistToDisk) { MsalCacheHelperWrapper cacheHelper = await GetCacheHelperAsync(async, cancellationToken).ConfigureAwait(false); cacheHelper.RegisterCache(tokenCache); } else { if (async) { await _lock.WaitAsync(cancellationToken).ConfigureAwait(false); } else { _lock.Wait(cancellationToken); } try { if (!_cacheAccessMap.TryGetValue(tokenCache, out _)) { tokenCache.SetBeforeAccessAsync(OnBeforeCacheAccessAsync); tokenCache.SetAfterAccessAsync(OnAfterCacheAccessAsync); _cacheAccessMap.Add(tokenCache, new CacheTimestamp()); } } finally { _lock.Release(); } } }