Skip to content

Commit 213b927

Browse files
Fix countdown event wait (#567)
Fix countdown event wait
1 parent 82d76e1 commit 213b927

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/coverlet.collector/Utilities/CountDownEvent.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,10 @@ public void Signal()
3131

3232
public void Wait()
3333
{
34-
// We wait on another thread to avoid to block forever
35-
// We could use Task/Task.Delay timeout trick but this api and collector are sync so to
36-
// avoid too much GetAwaiter()/GetResult() I prefer keep code simple.
37-
// This thread is created only one time where we pass coverage files
38-
var waitOnThread = new Thread(() => _countDownEvent.Wait());
39-
waitOnThread.Start();
40-
waitOnThread.Join(_waitTimeout);
34+
if (!_countDownEvent.Wait(_waitTimeout))
35+
{
36+
throw new TimeoutException($"CollectorCountdownEvent timeout after {_waitTimeout}");
37+
}
4138
}
4239
}
4340
}

0 commit comments

Comments
 (0)