Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Improve eventcounter test #26517

Merged
merged 1 commit into from
Sep 5, 2019
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
6 changes: 5 additions & 1 deletion tests/src/tracing/eventcounter/eventcounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ internal sealed class SimpleEventListener : EventListener
public string displayName;
public string displayUnits;
public int callbackCount;
public ManualResetEvent sawEvent;

public SimpleEventListener(string targetSourceName, EventLevel level)
{
Expand All @@ -53,6 +54,7 @@ public SimpleEventListener(string targetSourceName, EventLevel level)
means = new HashSet<int>();
args = new Dictionary<string, string>();
args.Add("EventCounterIntervalSec", "1");
sawEvent = new ManualResetEvent(false);
}

protected override void OnEventSourceCreated(EventSource source)
Expand Down Expand Up @@ -89,6 +91,7 @@ protected override void OnEventWritten(EventWrittenEventArgs eventData)
}
}
}
sawEvent.Set();
callbackCount++;
}
}
Expand All @@ -108,6 +111,7 @@ public bool validateMean()

public static int Main(string[] args)
{

// Create an EventListener.
using (SimpleEventListener myListener = new SimpleEventListener("SimpleEventSource", EventLevel.Verbose))
{
Expand All @@ -123,7 +127,7 @@ public static int Main(string[] args)
eventSource.WriteOne();
}

Thread.Sleep(3000);
myListener.sawEvent.WaitOne(-1); // Block until we see at least one event

if (!myListener.validateMean())
{
Expand Down