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))); }
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); }