T.T.T.
T.T.T.

Reputation: 34573

How to: Monitor progress of data in a pipe?

Have a 1MB pipe:

if (0 == CreatePipe(&hRead,&hWrite,0,1024*1024))
{
printf("CreatePipe failed\n");
return success;
}   

Sending 4000 bytes at a time (bytesReq = 4000)

while ((bytesReq = (FileSize - offset)) != 0)
{


//Send data to Decoder.cpp thread, converting to human readable CSV
        if ( (0 == WriteFile(hWrite,
                               readBuff,
                               bytesReq,
                               &bytesWritten,
                               0) ) || 
                               (bytesWritten != bytesReq) )
        {
             printf("WriteFile failed error = %d\n",GetLastError());
             break;
        } 

// Would like to update a status box with the amount of data in the pipe.
I would like to know if and how often it is getting full....



}  

4 bytes at a time being read in an other thread, on other end of pipe.

Upvotes: 0

Views: 833

Answers (1)

schoetbi
schoetbi

Reputation: 12886

Before reading the 4 bytes you can read the available bytes by using PeekNamedPipe

Upvotes: 1

Related Questions