AK.F1.Timing.Server.Threading.AutoResetEventSlimTest.wait_blocks_thread_for_specified_timeout_if_not_released C# (CSharp) Method

wait_blocks_thread_for_specified_timeout_if_not_released() private method

        public void wait_blocks_thread_for_specified_timeout_if_not_released()
        {
            using (var e = new AutoResetEventSlim())
            {
                var sw = Stopwatch.StartNew();
                e.Wait(0);
                sw.Stop();
                Assert.InRange(sw.Elapsed, TimeSpan.Zero, TimeSpan.FromMilliseconds(2));

                sw.Restart();
                e.Wait(100);
                sw.Stop();
                Assert.InRange(sw.Elapsed, TimeSpan.FromMilliseconds(80), TimeSpan.FromMilliseconds(140));
            }
        }