示例#1
0
    public static async Task <T> GetOrAddLazyAsync <T>(this ConcurrentTypeSet <object> set, Func <Task <T> > valueFactory)
    {
        Contracts.Requires.That(set != null);
        Contracts.Requires.That(valueFactory != null);

        return(await set.GetOrAdd(new AsyncLazy <T>(valueFactory)));
    }
示例#2
0
    public static T GetOrAddLazy <T>(this ConcurrentTypeSet <object> set, Func <T> valueFactory)
    {
        Contracts.Requires.That(set != null);
        Contracts.Requires.That(valueFactory != null);

        return(set.GetOrAdd(new Lazy <T>(valueFactory)).Value);
    }