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(); }
static void OnReadCB(IntPtr handle, IntPtr nread, ref uv_buf_t buf) { Tcp h = NativeHandle.GetDataFromHandle <Tcp>(handle); h.OnReadCB(nread); }
static void OnWriteCallback(IntPtr handle, int status) { var request = NativeHandle.GetDataFromHandle <WriteRequest>(handle); request.OnWriteCallback(status); }