/SignalR.Tests/CountDown.cs
C# | 40 lines | 35 code | 5 blank | 0 comment | 2 complexity | d507dd03531c9c89d629c66fac80f5b8 MD5 | raw file
Possible License(s): MIT
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- namespace SignalR.Tests
- {
- public class CountDown
- {
- private int _count;
- private ManualResetEventSlim _wh = new ManualResetEventSlim(false);
- public int Count
- {
- get
- {
- return _count;
- }
- }
- public CountDown(int count)
- {
- _count = count;
- }
- public void Dec()
- {
- if (Interlocked.Decrement(ref _count) == 0)
- {
- _wh.Set();
- }
- }
- public bool Wait(TimeSpan timeout)
- {
- return _wh.Wait(timeout);
- }
- }
- }