MSDN中对ReadFile有如下的解释:This function is designed for both synchronous and asynchronous operation. The ReadFileEx function is designed solely for asynchronous operation. It lets an application perform other processing during a file read operation.synchronous and asynchronous operation 是什么意思?望高手解答
就是说,你不必等着readfileex执行玩,就可以进行其他的操作。
这是必要的。
如何要涉及到很大的文件操作,有可能花5,6秒钟,不是异步的话就阻塞了,程序一直卡在这个函数上,你的鼠标,键盘都相应不了,用户可能认为是死机了,但异步操作不会出现这种问题。像是 并发
ReadFile()异步的时候,ReadFile函数会立即返回,然后执行ReadFile下面的语句。等数据读完后,系统会给你通知,让你去处理读到的数据。我们一般读的数据比较小,所以感觉不到同步,异步的区别。
异步例子:PostMessage
PostMessage在发出消息后立即返回(不管执行完没有),异步