One of the things that I really like in Windows API is overlapped I/O. I’ve written dozens of network servers using overlapped I/O (for both sockets and files) with only a limited number of threads. I’m also a driver writer, so that I know well how overlapped I/O is implemented “behind the scenes”.
The only thing that always bothered me is that some API functions don’t support overlapped mode. For instance, creating a file (i.e. calling CreateFile) always works synchronously. This is pity, because those methods could support overlapped (asynchronous) mode as well. For instance, when a file is created (or opened) – the file system driver receives an IRP_MJ_CREATE request, for which it may (and usually does) return STATUS_PENDING.
My question is: is there an option to open the file asynchronously nevertheless? (but please don’t tell me to create another thread to open the file).
I suspect that no asynchronous version exists because
CreateFileis fundamentally a blocking operation: http://www.osronline.com/article.cfm?article=484 (scroll down to Creates Are Even More Cancellable):