我看了MSDN.处理是:case ERROR_IO_PENDING: 
        { 
            // asynchronous i/o is still in progress 
 
            // do something else for a while 
            GoDoSomethingElse() ; 
 
            // check on the results of the asynchronous read 
            bResult = GetOverlappedResult(hFile, &gOverlapped, 
                &nBytesRead, FALSE) ; 
 
            // if there was a problem ... 
            if (!bResult) 
            { 
                // deal with the error code 
                switch (dwError = GetLastError()) 
                { 
                    case ERROR_HANDLE_EOF: 
                    { 
                        // we're reached the end of the file 
                        //during asynchronous operation 
                    } 
 
                    // deal with other error cases 
                } 
            } 
        } // end case 好像是等待的时间很短就去读串口了,但我已经等待了2妙还是不行.要怎么样处理这个问题呢?

解决方案 »

  1.   

    而我用的处理办法是:if( dwErrCode == ERROR_IO_PENDING )
    {
    while( !GetOverlappedResult(m_hCom,&m_ros,&dwRead,FALSE ) )
    {
    dwErrCode = GetLastError();
    if( dwErrCode == ERROR_IO_INCOMPLETE )
                      {
                           if ((GetTickCount()-dwTime) > nTimeOut)
         {
    ClearCommError( m_hCom, &dwErrorFlags, &ComStat );
    return QE_FAIL;
         }
         Sleep(1000) ;
         continue;
                      }
    else
    {
         ClearCommError( m_hCom, &dwErrorFlags, &ComStat ) ;
         if ( dwErrorFlags > 0)
         {
    //g_pEventLog->ErrorEventParamLog("Read COM Error: %u,<CE-%u>",dwErrCode,dwErrorFlags ) ;   
         }
    break ;
    }
    }
    }而用GetOverlappedResult返回的结果是true.那会是哪里的问题呢?