예제 #1
0
        public override void EndWrite(IAsyncResult asyncResult)
        {
            SerialAsyncResult sar = (SerialAsyncResult)asyncResult;

            if (sar.m_bIsRead)
            {
                throw new Exception("Invalid parameter: IAsyncResult is from a read");
            }
            sar.AsyncWaitHandle.WaitOne();
            if (!sar.m_bCompleted)
            {
                ((ManualResetEvent)sar.AsyncWaitHandle).Reset();
                sar.AsyncWaitHandle.WaitOne();
            }
            sar.Reset();
        }
예제 #2
0
        public override int EndRead(IAsyncResult asyncResult)
        {
            SerialAsyncResult sar = (SerialAsyncResult)asyncResult;

            if (!sar.m_bIsRead)
            {
                throw new Exception("Invalid parameter: IAsyncResult is not from a read");
            }
            sar.AsyncWaitHandle.WaitOne();
            if (!sar.m_bCompleted)
            {
                ((ManualResetEvent)sar.AsyncWaitHandle).Reset();
                sar.AsyncWaitHandle.WaitOne();
            }
            sar.Reset();

            return(m_iReadCount);
        }