[Win32] WaitForSingleObject on Named Pipe

Hey everybody -

I'm writing a small program that's supposed to use pipes (anonymous or named) as an IPC method. I'm having lots of trouble making the client wait for data to appear in the pipe.

On Linux, this is easy - I just use select() and set an infinite time. That worked with no problems. On Windows, I'm using WaitForSingleObject() to make it wait. WaitForSingleObject() returns immediately and doesn't wait at all. ConnectNamedPipe() on the server side does wait, so I know the pipe is created and the client has opened it.

Two questions:
1) Does WaitForSingleObject() even work with named/anonymous pipes? If not, what function can I use?
2) I'm using VS2003...sometimes compilers don't like certain functions. Is there something I need to know?

I hate to necromance my own thread, but I'd rather show the code I had working so save time.

The code above fails (or rather, WaitForSingleObject fails) when the above is run by two threads, not two processes. I originally tested it in two completely separate executables. Now that I want to run this within two threads in the same Windows DLL, WaitForSingleObject doesn't actually do any waiting.

I've scoured the net, and spent countless hours on this in Visual Studio. I'm beginning to wonder if it has something to do with the way the HANDLEs are created. Are there issues with using HANDLEs in separate threads like I am?