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

Expose OSThreadId and TimeStamp on EventWrittenEventArgs #19002

Merged
merged 13 commits into from
Aug 1, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add TimeStamp fetch and comparison to RuntimeEventSourceTest.
  • Loading branch information
brianrob committed Jul 18, 2018
commit 08cd1f7c97ee2d97b8c661490b3809a93d9d8434
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,21 @@ public SimpleEventListener(string name)
protected override void OnEventWritten(EventWrittenEventArgs eventData)
{
int osThreadId = -1;
DateTime timeStamp;
#if REFLECTION
PropertyInfo threadProperty = typeof(EventWrittenEventArgs).GetProperty("OSThreadId");
MethodInfo threadMethod = threadProperty.GetGetMethod();
osThreadId = (int)threadMethod.Invoke(eventData, null);
PropertyInfo timeStampProperty = typeof(EventWrittenEventArgs).GetProperty("TimeStamp");
MethodInfo timeStampMethod = timeStampProperty.GetGetMethod();
timeStamp = (DateTime)timeStampMethod.Invoke(eventData, null);
#endif

Console.WriteLine($"[{m_name}] ThreadID = {osThreadId} ID = {eventData.EventId} Name = {eventData.EventName}");
Console.WriteLine($"TimeStamp: {timeStamp.ToLocalTime()}");
Console.WriteLine($"LocalTime: {DateTime.Now}");
Console.WriteLine($"Difference: {DateTime.UtcNow - timeStamp}");
Assert.True("timeStamp < DateTime.UtcNow", timeStamp < DateTime.UtcNow);
for (int i = 0; i < eventData.Payload.Count; i++)
{
string payloadString = eventData.Payload[i] != null ? eventData.Payload[i].ToString() : string.Empty;
Expand Down