public PermaRequest(IntPtr handle) { Handle = handle; request = (uv_req_t *)handle; GCHandle = GCHandle.Alloc(this, GCHandleType.Normal); }
unsafe public static T GetObject <T>(IntPtr ptr) where T : class { uv_req_t *req = (uv_req_t *)ptr.ToPointer(); GCHandle *gchandle = (GCHandle *)req->data; return(gchandle->Target as T); }
public UVRequest(RequestType type) { var size = UVInterop.uv_req_size(type); _handle = Marshal.AllocHGlobal(size); _requestPointer = (uv_req_t*)_handle; GCHandle = GCHandle.Alloc(this, GCHandleType.Normal); }
public UVRequest(RequestType type) { var size = UVInterop.uv_req_size(type); _handle = Marshal.AllocHGlobal(size); _requestPointer = (uv_req_t *)_handle; GCHandle = GCHandle.Alloc(this, GCHandleType.Normal); }
protected PermaRequest(IntPtr handle, bool allocate) { Handle = handle; request = (uv_req_t *)handle; Data = IntPtr.Zero; if (allocate) { Data = UV.Alloc(sizeof(GCHandle)); } GCHandle = GCHandle.Alloc(this, GCHandleType.Normal); }
unsafe static void OnCallback(IntPtr handle, int status) { uv_req_t *uvRequest = (uv_req_t *)handle.ToPointer(); var request = GCHandle.FromIntPtr(uvRequest->data).Target as DisposeRequest; if (request == null) { throw new Exception("invalid callback"); } else { request._handle.Dispose(); request.Dispose(); } }
unsafe static void OnCallback(IntPtr handle, int status) { uv_req_t *uvRequest = (uv_req_t *)handle.ToPointer(); var request = GCHandle.FromIntPtr(uvRequest->data).Target as CallbackRequest; if (request == null) { Environment.FailFast("invalid callback"); } else { request.Callback(status); request.Dispose(); } }
unsafe public static T GetObject <T>(IntPtr ptr) where T : class { uv_req_t *req = (uv_req_t *)ptr.ToPointer(); return(GCHandle.FromIntPtr(req->data).Target as T); }