473,240 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,240 software developers and data experts.

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 3551
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
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
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
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
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
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
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
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
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,...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.