简体   繁体   中英

How do I open a file without blocking in windows?

I see the CreateFile function takes in a FILE_FLAG_OVERLAPPED parameter to make the file io non blocking. However, how can I make the CreateFile call itself non-blocking?

Unfortunately, CreateFile is synchronous. If you need it to be non-blocking, you are probably trying to do I/O in the UI thread. Avoid that.

You did not mention the programming language, so I will assume it is C++. You can use the standard library's threading facilities to offload the I/O intensive work into a worker thread. For example, you could wrap it in a packaged_task or async .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM