public async Task TestThread() { var sw = Stopwatch.StartNew(); await Simultaneously.Run(2, () => Sleep("test")); sw.ElapsedMilliseconds.ShouldBeInRange(100, 150); }
public async Task TestWithSlowFactory() { var counter = 0; var lazy = new AtomicLazy <string>(() => { Interlocked.Increment(ref counter); return(Delay("result")); }); await Simultaneously.Run(100, () => lazy.Value); lazy.Value.ShouldBe("result"); counter.ShouldBe(1); }