Skip to content
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
8 changes: 6 additions & 2 deletions src/coreclr/tests/src/tracing/eventpipe/reverse/reverse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,23 @@ public static async Task RunSubprocess(string serverName, Func<Task> beforeExecu

Logger.logger.Log($"running sub-process: {process.StartInfo.FileName} {process.StartInfo.Arguments}");

// use this DateTime rather than process.StartTime since the async callbacks might
// not happen till after the process is no longer around.
DateTime subprocessStartTime = DateTime.Now;

process.OutputDataReceived += new DataReceivedEventHandler((s,e) =>
{
if (!string.IsNullOrEmpty(e.Data))
{
stdoutSb.Append($"\n\t{(DateTime.Now - process.StartTime).TotalSeconds,5:f1}s: {e.Data}");
stdoutSb.Append($"\n\t{(DateTime.Now - subprocessStartTime).TotalSeconds,5:f1}s: {e.Data}");
}
});

process.ErrorDataReceived += new DataReceivedEventHandler((s,e) =>
{
if (!string.IsNullOrEmpty(e.Data))
{
stderrSb.Append($"\n\t{(DateTime.Now - process.StartTime).TotalSeconds,5:f1}s: {e.Data}");
stderrSb.Append($"\n\t{(DateTime.Now - subprocessStartTime).TotalSeconds,5:f1}s: {e.Data}");
}
});

Expand Down