public void SetDependencies(SafeSocketHandle socket, SafeRioCompletionQueueHandle completionQueue) { bool socketAddRefSuccess = false; bool completionQueueAddRefSuccess = false; try { socket.DangerousAddRef(ref socketAddRefSuccess); completionQueue.DangerousAddRef(ref completionQueueAddRefSuccess); } catch { if (socketAddRefSuccess) { socket.DangerousRelease(); } if (completionQueueAddRefSuccess) { completionQueue.DangerousRelease(); } throw; } _socket = socket; _completionQueue = completionQueue; }
protected override bool ReleaseHandle() { // There is no deallocation needed for this handle; it is deallocated as part of the socket. handle = IntPtr.Zero; _socket.DangerousRelease(); _completionQueue.DangerousRelease(); return(true); }