public async Task AmbientState() { var classWithAmbientState = new ClassWithAmbientState(); // TODO: Use the class with ambient state in parallel multiple times, call it on the same thread at least twice, put Thread.Sleep in between the calls Assert.Inconclusive(nameof(AmbientState)); }
public async Task AmbientState() { var classWithAmbientState = new ClassWithAmbientState(); var tasks = new Task[3]; for (int i = 0; i < 3; i++) { tasks[i] = ((Func <Task>)(async() => { classWithAmbientState.Do(); await Task.Delay(200).ConfigureAwait(false); classWithAmbientState.Do(); }))(); } await Task.WhenAll(tasks); }
public async Task AmbientState() { var classWithAmbientState = new ClassWithAmbientState(); var tasks = new Task[3]; for (int i = 0; i < 3; i++) { tasks[i] = Task.Run(() => { classWithAmbientState.Do(); Thread.Sleep(200); classWithAmbientState.Do(); }); } await Task.WhenAll(tasks); }