コード例 #1
0
 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");
 }
コード例 #2
0
    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");
    }
コード例 #3
0
    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));
    }