Re: Async File IO is not async?
Alex Ivanoff <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <[email protected]> |
No need for this. BeginWrite does this. -----Original Message----- From: Discussion of development on the .NET platform using any managed language [mailto:[email protected]] On Behalf Of Ryan Heath Sent: Friday, January 18, 2008 02:19 To: [email protected] Subject: Re: [DOTNET-CLR] Async File IO is not async? Hi Alex, I have altered your example into this [2] because the kb had this line [1] which made me wonder ;) // Ryan [1] Extending a File Another reason that I/O operations are completed synchronously is the operations themselves. On Windows NT, any write operation to a file that extends its length will be synchronous. [2] using System; System; using System.IO; System.IO; using System.Threading; System.Threading; namespace AsyncIOTest AsyncIOTest { class Program { static void Main() { 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)) { ManualResetEvent evt = new ManualResetEvent(false); Byte[] buffer = new Byte[512 * 1024 * 1024]; file.BeginWrite(buffer, 0, buffer.Length, Program.OnWriteComplete, evt); evt.WaitOne(); } File.Delete("out.test"); } static void OnWriteComplete(IAsyncResult ar) { ManualResetEvent evt = (ManualResetEvent)ar.AsyncState; evt.Set(); } } } On Jan 18, 2008 6:08 AM, Peter Ritchie <[email protected]> wrote: > > On Thu, 17 Jan 2008 22:09:27 -0600, Alex Ivanoff > <[email protected]> wrote: > > >A quick examination with Reflector reveals that BeginWrite and BeginRead > do not satisfy most (if not all) of the requirements of a "true" async IO > outlined here: http://support.microsoft.com/kb/156932. > > > > Did you reflect on FileStream.BeginWriteCore? > > > > > =================================== > This list is hosted by DevelopMentor(R) http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com > =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com