C++怎么实现异步的读取

我想把 pHttpFile->Read 部分,就是写入pBUFFER的过程改成异步的

 if (m_pCallback != NULL)
        m_pCallback->StartDownloadTile(iZoom, x, y, iType);

    TRY
    {
        pHttpFile = (CHttpFile*)m_pSession->OpenURL(strURL, 1, INTERNET_FLAG_TRANSFER_BINARY, NULL, 0);
    }
    CATCH (CInternetException, e)
    {
        if (m_pCallback != NULL)
            m_pCallback->FailDownloadTile(iZoom, x, y, iType);
        return 0;
    }
    END_CATCH
    if (pHttpFile == INVALID_HANDLE_VALUE)
    {
        if (m_pCallback != NULL)
            m_pCallback->FailDownloadTile(iZoom, x, y, iType);
        return 0;
    }

    // 接收PNG图片
    dwBufferSize = iBufferLen;
    dwRead = 0;
    do
    {
        dwSize = pHttpFile->Read(pBuffer + dwRead, dwBufferSize - dwRead);    // 读取图片  
        dwRead += dwSize;
    } while (dwSize > 0 && dwRead < dwBufferSize);
    // 关闭
    pHttpFile->Close();
    delete pHttpFile;

2个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐