Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save renestein/303250d207895758df3d to your computer and use it in GitHub Desktop.
Save renestein/303250d207895758df3d to your computer and use it in GitHub Desktop.
[TestMethod]
public async Task WithTaskFactory_When_Tasks_Are_Queued_Then_All_Tasks_Are_Executed()
{
const int NUMBER_OF_TASKS = 8096;
int numberOfTasksExecuted = 0;
var tasks = Enumerable.Range(0, NUMBER_OF_TASKS)
.Select(_ => TestTaskFactory.StartNew(() => Interlocked.Increment(ref numberOfTasksExecuted))).ToArray();
await Task.WhenAll(tasks);
Assert.AreEqual(NUMBER_OF_TASKS, numberOfTasksExecuted);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment