示例#1
0
        static void OnCloseHandle(IntPtr handle)
        {
            if (handle == IntPtr.Zero)
            {
                return;
            }

            NativeHandle nativeHandle = null;

            // Get gc handle first
            IntPtr pHandle = ((uv_handle_t *)handle)->data;

            if (pHandle != IntPtr.Zero)
            {
                GCHandle gcHandle = GCHandle.FromIntPtr(pHandle);
                if (gcHandle.IsAllocated)
                {
                    nativeHandle = gcHandle.Target as NativeHandle;
                    //Console.WriteLine("gcHandle free");
                    gcHandle.Free();

                    ((uv_handle_t *)handle)->data = IntPtr.Zero;
                }
            }


            // Release memory
            Libuv.FreeMemory(handle);
            nativeHandle?.OnClosed();
        }
示例#2
0
        static void OnReadCB(IntPtr handle, IntPtr nread, ref uv_buf_t buf)
        {
            Tcp h = NativeHandle.GetDataFromHandle <Tcp>(handle);

            h.OnReadCB(nread);
        }
示例#3
0
        static void OnWriteCallback(IntPtr handle, int status)
        {
            var request = NativeHandle.GetDataFromHandle <WriteRequest>(handle);

            request.OnWriteCallback(status);
        }