Async File IO is not async?

Alex Ivanoff <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.clr
Message-ID <[email protected]>
A very simple test program which writes out 512 MB:

using System;
using System.IO;
using System.Threading;

namespace AsyncIOTest
{
    class Program
    {
        static void Main()
        {
            FileStream file = File.Create("out.test", 0x1000, FileOptions.Asynchronous);

            ManualResetEvent evt = new ManualResetEvent(false);

            Byte[] buffer = new Byte[512 * 1024 * 1024];
            file.BeginWrite(buffer, 0, buffer.Length, Program.OnWriteComplete, evt);

            evt.WaitOne();
        }

        static void OnWriteComplete(IAsyncResult ar)
        {
            ManualResetEvent evt = (ManualResetEvent)ar.AsyncState;

            evt.Set();
        }
    }
}

On my machine BeginWrite takes about 12 sec followed by immediate call to OnWriteComplete. 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.

A bug?

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.