Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I open a file without blocking in windows?

Tags:

windows

winapi

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?

like image 623
Maxaon3000 Avatar asked Oct 21 '25 03:10

Maxaon3000


1 Answers

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.

like image 97
doug65536 Avatar answered Oct 22 '25 18:10

doug65536



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!