示例#1
0
        public override bool GetQueuedCompletionStatus(int timeout, out CompletionStatus completionStatus)
        {
            int    bytesTransferred;
            IntPtr completionKey;
            IntPtr overlappedAddress;

            bool result = UnsafeMethods.GetQueuedCompletionStatus(m_completionPortHandle, out bytesTransferred,
                                                                  out completionKey, out overlappedAddress, timeout);

            if (!result && overlappedAddress == IntPtr.Zero)
            {
                int error = Marshal.GetLastWin32Error();

                if (error == WaitTimeoutError)
                {
                    completionStatus = new CompletionStatus();

                    return(false);
                }

                throw new Win32Exception(error);
            }

            HandleCompletionStatus(out completionStatus, overlappedAddress, completionKey, bytesTransferred);

            return(true);
        }