CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2006
    Posts
    1

    Delay encountered while using ReadFile

    Hi,

    I am using ReadFile to read on a serial com port. At any given time, the bytes available to read are not more that 100.

    ReadFile(hFile, &inBuffer, nBytesToRead, &nBytesRead, NULL);

    When I use this funciton in the following steps:

    1. Find out how many bytes are available to read and store it in nBytesToRead.
    2. Call ReadFile(hFile, &inBuffer, nBytesToRead, &nBytesRead, NULL);

    This function returns almost instantaneously after reading nBytesToRead bytes.


    But when I use in this way:

    1. Call ReadFile(hFile, &inBuffer, 1024, &nBytesRead, NULL);

    1024 is any random number. This function, tough reads the available number of bytes in the port, it takes 2000ms more to return.

    Can anyone please explain, why there is this additional delay being introduced ?

    Thanks,
    Mihir.

  2. #2
    Join Date
    Sep 2003
    Location
    M...N
    Posts
    220

    Re: Delay encountered while using ReadFile

    This is interesting. Pump it and hope some guru can help explain.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured