Skip to content

Commit

Permalink
Merge pull request #380 from mono/fix-flaky-test
Browse files Browse the repository at this point in the history
Ensure all threads have started before test pauses
  • Loading branch information
nosami authored Feb 15, 2023
2 parents 0d0854d + d4307f6 commit 5d69343
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,19 @@ public void FunctionBreakpoint ()

public void MultipleThreads ()
{
var threadStart = new ManualResetEvent(false);
for (var i = 0; i < 10; i++)
{
var thread = new Thread(() => Thread.Sleep(10000));

var thread = new Thread(() =>
{
threadStart.Set();
Thread.Sleep(10000);
});
thread.IsBackground = true;
thread.Name = "Thread " + i;
thread.Start();
threadStart.WaitOne();
threadStart.Reset();
}

Console.WriteLine("Done"); /*536f5570-c182-4d21-ad23-ae9f6a8b2892*/
Expand Down

0 comments on commit 5d69343

Please sign in to comment.