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(); }
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); }