Skip to content

Commit

Permalink
Address GetTimestamp failure
Browse files Browse the repository at this point in the history
Fixes #18 in the most basic way possible by catching the exception and returning null.
  • Loading branch information
contre committed Jan 24, 2020
1 parent 6165eea commit 315f84d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion source/WindowsAPICodePack/Sensors/ObjectModel/SensorReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ internal static SensorReport FromNativeReport(Sensor originator, ISensorDataRepo
{

SystemTime systemTimeStamp = new SystemTime();
iReport.GetTimestamp(out systemTimeStamp);
try
{
iReport.GetTimestamp(out systemTimeStamp);
}
catch (System.Runtime.InteropServices.COMException ex)
{
System.Diagnostics.Trace.WriteLine(ex);
return null;
}
FILETIME ftTimeStamp = new FILETIME();
SensorNativeMethods.SystemTimeToFileTime(ref systemTimeStamp, out ftTimeStamp);
long lTimeStamp = (((long)ftTimeStamp.dwHighDateTime) << 32) + (long)ftTimeStamp.dwLowDateTime;
Expand Down

0 comments on commit 315f84d

Please sign in to comment.