private static void RefWorker(IntPtr handleValue) { Native.MyCriticalHandleStruct handleStruct = new Native.MyCriticalHandleStruct() { Handle = new MyCriticalHandle() { Handle = handleValue } }; Native.Ref(ref handleStruct, s_handleCallback); Assert.AreEqual(handleValue.ToInt32(), handleStruct.Handle.Handle.ToInt32(), "Handle value"); }
private static void InWorker(IntPtr handleValue) { Native.MyCriticalHandleStruct handleStruct = new Native.MyCriticalHandleStruct() { Handle = new MyCriticalHandle() { Handle = handleValue } }; IntPtr value; value = Native.In(handleStruct, s_handleCallback); Assert.AreEqual(handleValue.ToInt32(), value.ToInt32(), "Handle value"); }
public static void RefModify() { IntPtr handleValue1 = MyCriticalHandle.GetUniqueHandle(); IntPtr handleValue2 = MyCriticalHandle.GetUniqueHandle(); Native.MyCriticalHandleStruct handleStruct = new Native.MyCriticalHandleStruct() { Handle = new MyCriticalHandle() { Handle = handleValue1 } }; Assert.Throws <NotSupportedException>(() => Native.RefModify(handleValue2, ref handleStruct, null)); }