Re: Async File IO is not async?
Alex Ivanoff <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <[email protected]> |
Read the article I mentioned earlier http://support.microsoft.com/kb/156932. To sum it up: 1. File needs to be opened with FILE_FLAG_NO_BUFFERING to avoid usage of cache manager which is synchronous. From MSDN: 2. File access must begin at byte offsets within a file that are integer multiples of the volume sector size. 3. File access must be for numbers of bytes that are integer multiples of the volume sector size. For example, if the sector size is 512 bytes, an application can request reads and writes of 512, 1024, 1536, or 2048 bytes, but not of 335, 981, or 7171 bytes. 4. Buffer addresses for read and write operations should be sector aligned, which means aligned on addresses in memory that are integer multiples of the volume sector size. Depending on the disk, this requirement may not be enforced. -----Original Message----- From: Discussion of development on the .NET platform using any managed language [mailto:[email protected]] On Behalf Of Stoyan Damov Sent: Friday, January 18, 2008 02:45 To: [email protected] Subject: Re: [DOTNET-CLR] Async File IO is not async? On Jan 18, 2008 10:19 AM, Ryan Heath <[email protected]> wrote: > Hi Alex, > > I have altered your example into this [2] > because the kb had this line [1] which made me wonder ;) > > // Ryan > ... > using (FileStream file = File.Create("out.test", 0x1000, > FileOptions.Asynchronous)) > { > file.Position = 512 * 1024 * 1024 - 1; > file.WriteByte(0); > } > > using (FileStream file = File.Open("out.test",FileMode.Open, > FileAccess.Write)) > { ... ^^^ 2nd ctor doesn't open the file in async mode. Also, I did the same thing, opened it async, opened it with 2 different async-enabling ctors, verified fiel.IsAsync == true and still the entire write goes as 1 synchronous call, wtf? Cheers =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com