Exemplo n.º 1
0
        private async Task UpdateCacheDataAsync(ITokenCacheSerializer tokenCache)
        {
            await _lock.WaitAsync().ConfigureAwait(false);

            try
            {
                if (!_cacheAccessMap.TryGetValue(tokenCache, out CacheTimestamp lastRead) || lastRead.Value < _lastUpdated)
                {
                    _data = await MergeCacheData(_data, tokenCache.SerializeMsalV3()).ConfigureAwait(false);
                }
                else
                {
                    _data = tokenCache.SerializeMsalV3();
                }

                _cacheAccessMap.GetOrCreateValue(tokenCache).Update();

                _lastUpdated = DateTime.UtcNow;
            }
            finally
            {
                _lock.Release();
            }

            if (Updated != null)
            {
                foreach (Func <TokenCacheUpdatedArgs, Task> handler in Updated.GetInvocationList())
                {
                    await handler(new TokenCacheUpdatedArgs(this)).ConfigureAwait(false);
                }
            }
        }
Exemplo n.º 2
0
 private void OnUpdated()
 {
     if (Updated != null)
     {
         foreach (Action handler in Updated.GetInvocationList())
         {
             handler.BeginInvoke(null, null);
         }
     }
 }