Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics;
using System.Threading;

public class AutoResetEventCtor
Expand Down Expand Up @@ -70,8 +72,8 @@ public bool PosTest2()
{
bool retVal = true;
AutoResetEvent are;
long ticksBefore;
long ticksAfter;
Stopwatch sw;
long elapsedTicks;

TestLibrary.TestFramework.BeginScenario("PosTest1: AutoResetEvent.Ctor(false)");

Expand All @@ -80,19 +82,20 @@ public bool PosTest2()
// true means that the initial state should be signaled
are = new AutoResetEvent(false);

ticksBefore = DateTime.Now.Ticks;
sw = Stopwatch.StartNew();

// verify that the autoreset event is signaled
// if it is not signaled the following call will block for ever
TestLibrary.TestFramework.LogInformation("Calling AutoResetEvent.WaitOne()... if the event is signaled it will not wait long enough");
are.WaitOne(c_MILLISECONDS_TOWAIT);

ticksAfter = DateTime.Now.Ticks;
sw.Stop();
elapsedTicks = sw.Elapsed.Ticks;

if (c_DELTA < Math.Abs((ticksAfter - ticksBefore) - (c_MILLISECONDS_TOWAIT*10000)))
if (c_DELTA < Math.Abs(elapsedTicks - (c_MILLISECONDS_TOWAIT*10000)))
{
TestLibrary.TestFramework.LogError("002", "AutoResetEvent did not wait long enough... this implies that the parameter was not respected.");
TestLibrary.TestFramework.LogError("002", " WaitTime=" + (ticksAfter-ticksBefore) + " (ticks)");
TestLibrary.TestFramework.LogError("002", " WaitTime=" + elapsedTicks + " (ticks)");
TestLibrary.TestFramework.LogError("002", " Execpted=" + (c_MILLISECONDS_TOWAIT*10000) + " (ticks)");
TestLibrary.TestFramework.LogError("002", " Acceptable Delta=" + c_DELTA + " (ticks)");
retVal = false;
Expand Down