Skip to content

Commit

Permalink
Ensure all threads have started before test pauses
Browse files Browse the repository at this point in the history
  • Loading branch information
nosami committed Feb 15, 2023
1 parent 0d0854d commit d4307f6
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 d4307f6

Please sign in to comment.