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