Ejemplo n.º 1
0
            /// <summary>
            /// Gets the value from the cache, or creates it
            /// </summary>
            /// <param name="p">The method used to create the value</param>
            /// <returns>The value or null</returns>
            public async Task<T> TryGetValueAsync(string subkey, Func<Task<T>> p)
            {
                T res;
                if ((res = await m_parent.TryGetValue(GetKeyForSubkey(subkey)) as T) == null)
                    await m_parent.AddItem(GetKeyForSubkey(subkey), res = await p());

                return res;
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Gets the value from the cache, or creates it
            /// </summary>
            /// <param name="p">The method used to create the value</param>
            /// <returns>The value or null</returns>
            public async Task<T> TryGetValueAsync(Func<Task<T>> p)
            {
                T res;
                if ((res = await m_parent.TryGetValue(m_key) as T) == null)
                    await m_parent.AddItem(m_key, res = await p());

                return res;
            }