By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,865 Members | 1,365 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,865 IT Pros & Developers. It's quick & easy.

Async I/O always better than sync I/O?

P: n/a
Hi,

Is Async I/O (e.g. NetworkStream.Begin/End Read/Write) always better than
synchronous I/O? At least as good?

When I don't concern about easy or difficult to write code, should I always
use Async I/O?

Thanks!
Jun 27 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On May 20, 1:27 pm, "Ryan Liu" <r...@powercati.comwrote:
Hi,

Is Async I/O (e.g. NetworkStream.Begin/End Read/Write) always better than
synchronous I/O? At least as good?

When I don't concern about easy or difficult to write code, should I always
use Async I/O?

Thanks!
Well, that really depends on what you want to achieve. If you have a
CPU bound task you don't want to delay while doing I/O, async is the
way to go. On the other hand if you application is mainly doing I/O
you will most likely not see a big gain by using async I/O. Also,
synchronous I/O is a lot simpler than async I/O so even tough you say
you don't care, you'll be facing more problems if you go with async I/
O if you don't really need it but of course it's your choice.

Regards,
Brian
Jun 27 '08 #2

P: n/a
Ryan Liu wrote:
Is Async I/O (e.g. NetworkStream.Begin/End Read/Write) always better than
synchronous I/O? At least as good?
If your code is I/O bound (so you don't have spare work to do) and
doesn't need to scale (so you'd have more parallel I/O-bound code
running), then you don't need the complexity of async.

Otherwise, assuming you write it correctly, you can scale to more
parallel I/O operations and you can fit in more compute work while I/O
is pending, if you use async.
When I don't concern about easy or difficult to write code, should I always
use Async I/O?
Don't underestimate the cost (in maintenance, debugging, design,
implementation, documentation, explanation to other coders) of async
code.

-- Barry

--
http://barrkel.blogspot.com/
Jun 27 '08 #3

P: n/a
On Tue, 20 May 2008 04:27:37 -0700, Ryan Liu <rl**@powercati.comwrote:
Is Async I/O (e.g. NetworkStream.Begin/End Read/Write) always better
than
synchronous I/O? At least as good?
"Better" is far too vague to really able to answer. Except perhaps that
inasmuch as "better" can carry many meanings, then obviously one
particular i/o paradigm cannot possibly always be "better". :)
When I don't concern about easy or difficult to write code, should I
always
use Async I/O?
Personally, I like the async i/o API and don't find it more difficult. If
anything, I find it less difficult. But I have a fair amount of
experience with asynchronous i/o programming and the async i/o API works
well for me. Even so, I don't use it when I'm dealing with brief i/o or
i/o on a small scale that I know won't be interrupted, even if that i/o
will take longer.

Sometimes simplicity is "better" than efficiency.

Pete
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.