John, I read files asynchronously using I/O completion ports via P/Invoke. I spent a lot of time writing the P/Invoke signatures for calls like "CreateIoCompletionPort", "ReadFile", "WriteFile", "CreateEvent", etc. I don't know if there is a better and equally efficient way to do this (other than Managed C++ and P/Invoke); I am curious to know also.
Srihari On Wed, 8 Sep 2004, John Davis wrote: > Got asked for more details. > > If you look at the latest docs on FileStream.BeginRead it says ... > > By default, FileStream opens the operating system handle synchronously. > In Windows, this slows down asynchronous methods. If asynchronous > methods are used, use the FileStream(IntPtr, FileAccess, Boolean, Int32, > Boolean) constructor. > > This implies that the IntPtr needs to be a file handle from a call to > CreateFile where the FILE_FLAG_OVERLAPPED was specified. Looks like the > current implementation defaults to async requests (ie > FileStream.BeginRead) occuring in the thread pool via blocking calls to > the file handle. I would prefer to have my async operations fire > through an IO completion port, like the socket implementation. Usually > more efficient if done this way. > > > John Davis <[EMAIL PROTECTED]> wrote: > Is it possible to get the IntPtr file handle for this call without doing interop? > > > [C#]public FileStream( IntPtr handle, FileAccess access, bool ownsHandle, int > bufferSize, bool isAsync); > > > > --------------------------------- > Do you Yahoo!? > New and Improved Yahoo! Mail - 100MB free storage! > > =================================== > This list is hosted by DevelopMentor� http://www.develop.com > Some .NET courses you may be interested in: > > Essential .NET: building applications and components with CSharp > August 30 - September 3, in Los Angeles > http://www.develop.com/courses/edotnet > > View archives and manage your subscription(s) at http://discuss.develop.com > > > > --------------------------------- > Do you Yahoo!? > Win 1 of 4,000 free domain names from Yahoo! Enter now. > > =================================== > This list is hosted by DevelopMentor� http://www.develop.com > Some .NET courses you may be interested in: > > Essential .NET: building applications and components with CSharp > August 30 - September 3, in Los Angeles > http://www.develop.com/courses/edotnet > > View archives and manage your subscription(s) at http://discuss.develop.com > =================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in: Essential .NET: building applications and components with CSharp August 30 - September 3, in Los Angeles http://www.develop.com/courses/edotnet View archives and manage your subscription(s) at http://discuss.develop.com
