in Source/Tx.Windows/EtwNative/EtwFileReader.cs [187:243]
private void MergeTracesAndProcess()
{
int error;
_handles = new ulong[_logFiles.Length];
IntPtr startTime = ConvertDateTime(_startTime);
IntPtr endTime = ConvertDateTime(_endTime);
for (int i = 0; i < _logFiles.Length; i++)
{
_handles[i] = EtwNativeMethods.OpenTrace(ref _logFiles[i]);
if (_handles[i] == EtwNativeMethods.InvalidHandle)
{
error = Marshal.GetLastWin32Error();
if (error == EtwNativeMethods.ErrorNotFound)
{
_observer.OnError(new FileNotFoundException("Could not find file " + _logFiles[i].LogFileName));
return;
}
_observer.OnError(new Win32Exception(error));
return;
}
}
try
{
error = EtwNativeMethods.ProcessTrace(_handles, (uint)_handles.Length, startTime, endTime);
}
catch (Exception ex)
{
_observer.OnError(ex);
return;
}
finally
{
if (startTime != IntPtr.Zero)
{
Marshal.FreeHGlobal(startTime);
startTime = IntPtr.Zero;
}
if (endTime != IntPtr.Zero)
{
Marshal.FreeHGlobal(endTime);
endTime = IntPtr.Zero;
}
}
if (error != 0)
{
_observer.OnError(new Win32Exception(error));
return;
}
_observer.OnCompleted();
}