public override string ToString() { return(_value.ToString()); }
private static void VerifyPointer(UIntPtr ptr, ulong expected) { Assert.Equal(expected, ptr.ToUInt64()); uint expected32 = (uint)expected; if (expected32 != expected) { Assert.Throws<OverflowException>(() => ptr.ToUInt32()); return; } Assert.Equal(expected32, ptr.ToUInt32()); Assert.Equal(expected.ToString(), ptr.ToString()); Assert.Equal(ptr, new UIntPtr(expected)); Assert.True(ptr == new UIntPtr(expected)); Assert.False(ptr != new UIntPtr(expected)); Assert.NotEqual(ptr, new UIntPtr(expected + 1)); Assert.False(ptr == new UIntPtr(expected + 1)); Assert.True(ptr != new UIntPtr(expected + 1)); }
private void SetThreadAffinity(int threadIndex, IntPtr hThread) { UIntPtr newThreadAffinity = new UIntPtr((uint)threadIndex + 1); uint result = Native.SetThreadAffinityMask(hThread, newThreadAffinity); if (result == 0) { int errorCode = Marshal.GetLastWin32Error(); Log(string.Format("Thread affinity setting failed. New: {0}, Win32Error: {1}", newThreadAffinity.ToString(), errorCode)); } else { Log(string.Format("Thread affinity setting succeeded. Previouse: {0}, New: {1}", result, newThreadAffinity.ToString())); } }