【发布时间】:2013-02-08 05:47:41
【问题描述】:
考虑以下场景:
auto h = CreateFile(...);
ReadFileEx(h, ...); // Asynchronous read for a large block of data. say, 1GB.
CloseHandle(h);
// If the read has not yet finished here, what will happen? Big Bang???
【问题讨论】:
-
@Alok,你能推荐我到具体的 MSDN 页面吗?
-
如果可以的话,尝试使用C89标准中描述的文件管理功能linux.die.net/man/3/fopen和linux.die.net/man/3/fclose
-
另外,您可以告诉操作系统使用 mmap 为您执行异步读取,并将文件直接映射到内存。 (对于一些指针,请参阅linuxquestions.org/questions/programming-9/…)
-
@xmllmx:这是我最好的猜测。我找不到任何明确说明的参考资料。
-
从事这种冒险行为的动机是什么?这不正是为什么
ReadFileEx函数的最后一个参数允许您指定一个指向在操作完成时调用的函数的指针吗?在那里拨打CloseHandle。
标签: c windows exception file-io asynchronous