PC Review


Reply
Thread Tools Rate Thread

BeginXXX / Async IO

 
 
Chad Z. Hower aka Kudzu
Guest
Posts: n/a
 
      31st Jan 2004
The docs are not clear on a few points, particularly one. And considering
that the excerpted Async examples on MSDN have a bad link to the master, and
tha the one complete example appears to have a small bug that it wont compile
(Havent tried it, but syntax in one spot looks wrong and does not match
others, nor compile when that one item is duplicated) Im left to guess.

BeginRead/Write accepts a length of bytes to read/write. It makes a call back
at a later time when this is "complete". You can then use EndRead to
determine how many bytes were read. EndWrite does not return a value.

a) Can the call back ever be made in which the number of bytes is less than
requested in BeginRead - yet it not be an error. That is its just calling
back to you to say "I did this much" and you have to call BeginRead again.
Similar to how non blocking sockets work in Winsock. Or, is it that if
EndRead ever returns less bytes than requested in BeginRead, it should be
considered an error.

b) Same question - but EndWrite. But since EndWrite does not return a size,
it should thus be assumed that writes are ALWAYS completed successfully when
the call back is made, unless EndWrite raises an exception.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"


ELKNews - Get your free copy at http://www.atozedsoftware.com

 
Reply With Quote
 
 
 
 
Chris Taylor
Guest
Posts: n/a
 
      1st Feb 2004
Hi,

The async read callback can be called before the requested number of bytes
have been read, in this case it is up to you to restart a new async read.

As for the async write, the EndWrite will block untill the requested number
of bytes have been sent. So even if the callback got called prematurely
(Which I doubt would happen!), the EndWrite call would block. So if unless
there has been an error, the requested bytes have been written to the stream
once EndWrite returns.

Hope this helps

--
Chris Taylor
http://dotnetjunkies.com/WebLog/chris.taylor/
"Chad Z. Hower aka Kudzu" <(E-Mail Removed)> wrote in message
news:Xns9481EA53280A9cpub@127.0.0.1...
> The docs are not clear on a few points, particularly one. And considering
> that the excerpted Async examples on MSDN have a bad link to the master,

and
> tha the one complete example appears to have a small bug that it wont

compile
> (Havent tried it, but syntax in one spot looks wrong and does not match
> others, nor compile when that one item is duplicated) Im left to guess.
>
> BeginRead/Write accepts a length of bytes to read/write. It makes a call

back
> at a later time when this is "complete". You can then use EndRead to
> determine how many bytes were read. EndWrite does not return a value.
>
> a) Can the call back ever be made in which the number of bytes is less

than
> requested in BeginRead - yet it not be an error. That is its just calling
> back to you to say "I did this much" and you have to call BeginRead again.
> Similar to how non blocking sockets work in Winsock. Or, is it that if
> EndRead ever returns less bytes than requested in BeginRead, it should be
> considered an error.
>
> b) Same question - but EndWrite. But since EndWrite does not return a

size,
> it should thus be assumed that writes are ALWAYS completed successfully

when
> the call back is made, unless EndWrite raises an exception.
>
>
> --
> Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
> "Programming is an art form that fights back"
>
>
> ELKNews - Get your free copy at http://www.atozedsoftware.com
>



 
Reply With Quote
 
Chad Z. Hower aka Kudzu
Guest
Posts: n/a
 
      10th Feb 2004
"Chris Taylor" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):
> The async read callback can be called before the requested number of
> bytes have been read, in this case it is up to you to restart a new
> async read.



Thanks. The MSDN docs should really be updated about this...


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"


ELKNews - Get your free copy at http://www.atozedsoftware.com

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Connect without async but get timeout error when async=true Joseph Microsoft ADO .NET 5 16th Jul 2008 10:13 PM
writing an async client (sockets/async/thread) asharda@woh.rr.com Microsoft C# .NET 8 17th Mar 2008 10:04 PM
Any harm in using Async=true to sql server 2005 for non-async db calls Chris Becker Microsoft ADO .NET 1 23rd Mar 2007 12:18 AM
Async in asp.net 2.0 and async application block =?Utf-8?B?TGVuZWlzZTQ0?= Microsoft Dot NET 2 4th Jan 2006 03:41 AM
Threading: ThreadStart vs BeginXXX/EndXXX AMI Microsoft Dot NET Framework 6 16th Nov 2004 08:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:39 AM.