Fixed an OverflowException when trying to use (unsupported) 64-bit thread affinity masks on 32-bit systems.

This commit is contained in:
Michael Möller
2014-12-30 22:49:32 +00:00
parent f054320731
commit 7614363308
2 changed files with 12 additions and 6 deletions
+10 -4
View File
@@ -4,7 +4,7 @@
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (C) 2010 Michael Möller <mmoeller@openhardwaremonitor.org>
Copyright (C) 2010-2014 Michael Möller <mmoeller@openhardwaremonitor.org>
*/
@@ -29,9 +29,15 @@ namespace OpenHardwareMonitor.Hardware {
ref mask) != 0)
return 0;
return result;
} else { // Windows
return (ulong)NativeMethods.SetThreadAffinityMask(
NativeMethods.GetCurrentThread(), (UIntPtr)mask);
} else { // Windows
UIntPtr uIntPtrMask;
try {
uIntPtrMask = (UIntPtr)mask;
} catch (OverflowException) {
throw new ArgumentOutOfRangeException("mask");
}
return (ulong)NativeMethods.SetThreadAffinityMask(
NativeMethods.GetCurrentThread(), uIntPtrMask);
}
}
+2 -2
View File
@@ -10,5 +10,5 @@
using System.Reflection;
[assembly: AssemblyVersion("0.7.0.0")]
[assembly: AssemblyInformationalVersion("0.7.0 Beta")]
[assembly: AssemblyVersion("0.7.1.0")]
[assembly: AssemblyInformationalVersion("0.7.1 Beta")]