< Summary

Information
Class: LeetCode.Concurrency.PrintInOrder.PrintInOrderManualResetEvent
Assembly: LeetCode
File(s): D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Concurrency\PrintInOrder\PrintInOrderManualResetEvent.cs
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 42
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
First(...)100%11100%
Second(...)100%11100%
Third(...)100%11100%

File(s)

D:\a\LeetCode-CS\LeetCode-CS\source\LeetCode\Concurrency\PrintInOrder\PrintInOrderManualResetEvent.cs

#LineLine coverage
 1// --------------------------------------------------------------------------------
 2// Copyright (C) 2025 Eugene Eremeev (also known as Yevhenii Yeriemeieiv).
 3// All Rights Reserved.
 4// --------------------------------------------------------------------------------
 5// This software is the confidential and proprietary information of Eugene Eremeev
 6// (also known as Yevhenii Yeriemeieiv) ("Confidential Information"). You shall not
 7// disclose such Confidential Information and shall use it only in accordance with
 8// the terms of the license agreement you entered into with Eugene Eremeev (also
 9// known as Yevhenii Yeriemeieiv).
 10// --------------------------------------------------------------------------------
 11
 12namespace LeetCode.Concurrency.PrintInOrder;
 13
 14/// <inheritdoc />
 15public class PrintInOrderManualResetEvent : IPrintInOrder
 16{
 317    private readonly ManualResetEvent _firstPrint = new(false);
 318    private readonly ManualResetEvent _secondPrint = new(false);
 19
 20    public void First(Action printFirst)
 321    {
 322        printFirst.Invoke();
 23
 324        _firstPrint.Set();
 325    }
 26
 27    public void Second(Action printSecond)
 328    {
 329        _firstPrint.WaitOne();
 30
 331        printSecond.Invoke();
 32
 333        _secondPrint.Set();
 334    }
 35
 36    public void Third(Action printThird)
 337    {
 338        _secondPrint.WaitOne();
 39
 340        printThird.Invoke();
 341    }
 42}