Re: Overlapped file IO

Alex Ivanoff <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.clr
Message-ID <[email protected]>
FileStream.BeginXXX/EndXXX methods are asynchronous, but not overlapped. You cannot specify where to start reading/writing (Win32 OVERLAPPED.Offset/OffsetHigh members) nor can you issue multiple read/write operations against the same file handle at the same time. From MSDN:

"EndRead must be called exactly for every call to BeginRead. Failing to end a read process before beginning another read can cause undesirable behavior such as deadlock."

This is not overlapped at all.


-----Original Message-----
From: Discussion of development on the .NET platform using any managed language [mailto:[email protected]] On Behalf Of Dan Farino
Sent: Monday, November 19, 2007 17:42
To: [email protected]
Subject: Re: [DOTNET-CLR] Overlapped file IO

Yes it does (except on Windows 9x). For FileStream, use the constructor:

public FileStream(string path, FileMode mode, FileSystemRights rights,
FileShare share, int bufferSize, FileOptions options)

Make sure you pass in FileOptions.Asynchronous. Then, use
BeginRead/Write and EndRead/Write. This uses overlapped I/O. (The only
part that is still synchronous is the constructor since there is no
async version of the underlying CreateFile Win32 call.)

Other classes such as Socket also use overlapped I/O when you use
BeginXXX/EndXXX. In the case of Socket and others, you don't need to
pass any special flags in like you have to with FileStream's
FileOptions.

-----Original Message-----
From: Discussion of development on the .NET platform using any managed
language [mailto:[email protected]] On Behalf Of Alex
Ivanoff
Sent: Monday, November 19, 2007 2:44 PM
To: [email protected]
Subject: [DOTNET-CLR] Overlapped file IO

Does .NET 2.0 have support for overlapped IO or do I need to implement
one myself?

Alex

===================================
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.