473,503 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
3 3562
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
2117
by: Dan | last post by:
I have seen differing ways to pass values to a class: $db=new mysqlclass('localhost','user','passwd','database'); ..... OR $db=new mysqlclass() $db->host='localhost'; $db->user='user';...
4
3090
by: Steven T. Hatton | last post by:
You can scroll down to the last line of this post in order to find the question I really want to discuss. I was just pondering the competing applicability of C vs. C++ in certain problem...
0
1805
by: Passynkov, Vadim | last post by:
I am using Asynchronous Query Processing interface from libpq library. And I got some strange results on Solaris My test select query is 'SELECT * from pg_user;' and I use select system...
1
1118
by: Chad A. Beckner | last post by:
Hey all, I am developing a workshop registration system, and am new to ASP .NET. On my first page, I want to list the "categories" available along with the number of "workshops" related to that...
5
1507
by: serge | last post by:
Is it generally or almost always better to have multiple small SPs and functions to return a result set instead of using a single big 1000+ lines SP? I have one SP for example that is 1000+...
10
1647
by: Newbie | last post by:
Hi all, I'm looking for a way to send newsletter to my subscribers (1000+ in total). I've managed to do it using .NET system.net.mail.smtpclient's sendAsync. I read the email addresses from a...
0
1465
by: Denis | last post by:
Hello, does anyone know of an easy way to do a Bi-Directional Data Sync between SQL Server and an Access database. I want to make sure that both Access (on a desktop app) and SQL Server (on...
0
1144
by: Bassem | last post by:
Hello, Invoking DrawToBitmap of WebBrowser, the WebBrowser fires an event when it is done. Now, I'm inside a sequential executing of a pre-implemented system; big do-while which contains do#1,...
0
7084
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7458
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.