[fpc-pascal] How to poll for a byte in Input?
Michael Van Canneyt
michael at freepascal.org
Fri Dec 9 22:51:01 CET 2011
On Fri, 9 Dec 2011, tcoq wrote:
> I have found and tried WaitForSingleObject, using the following syntax:
>
> ThereIsACharacterToRead := WaitForSingleObject(StdInputHandle,0) = 0;
> While ThereIsACharacterToRead do
> begin
> aByte := InputStream.ReadByte;
> ThereIsACharacterToRead := WaitForSingleObject(StdInputHandle,0) = 0;
> end;
>
> However, WaitForSingleObject always gives back 0, meaning there should be
> information. My logging tells me that information arrives at least 500ms
> afterwards and that ReadByte waits for it. Something is not working.
I do not think this is correct if the timeout is zero.
You should specify a timeout.
Michael.
More information about the fpc-pascal
mailing list