Solved:
I think this is just by poor design in the file system. I have seen the same problem when I worked with communication ports, opening/closing them.
Unfortunately I think the simplest solution would be to just retry to create the file a number of times if you get an INVALID_HANDLE_VALUE
. GetLastError()
might also give you a better way of detecting this particular INVALID_HANDLE_VALUE
.
I would have preferred overlapped I/O, but their CloseHandle()
and DeleteFile()
don't handle overlapped operations :(