On ADO.NET 2.0 Asynchronous Operations

| No Comments | No TrackBacks

Originally Posted 4/30/2005 and imported here from my old blog.

Okay, it’s cool that ADO.NET 2.0 now supports asynchronous operations like BeginExecuteReader. That’s the good news. The bad news is that the DataTable Load does not. Suppose you use BeginExecuteReader to execute a query and (for some really dumb reason) it returns 10,000 rows. If you want to move that DataReader into a DataTable, you can use the new DataTable.Load and point to the DataReader. That's cool, and fast(er) than doing it yourself. However, it turns out that DataTable.Load takes far more time than the initial query. That’s because when SQL Server returns from the query, it’s not really done. It has just built the first buffer of rows and told ADO to come and get them. At this point DataReader.Read (called by Load behind the scenes) starts fetching those rows and SQL Server turns around and starts finding more. Unfortunately, all of this takes place synchronously so your cool progress bar incremented while the asynchronous operation was running does not get bumped. Nope, the Load method also eats the events fired by the Timer control too so plan B won’t work either.

It would have been nice to enable asynchronous Load and Fill as well as Execute. I would settle for progress events on Load and Fill... This would give me a chance to say “Forget it... this is taking too long” or “See folks, it's still working and not really locked up”.

No TrackBacks

TrackBack URL: http://betav.com/blogadmin/mt-tb.cgi/128

Leave a comment

Pages

Powered by Movable Type 4.21-en

About this Entry

This page contains a single entry by William Vaughn published on April 30, 2005 12:08 PM.

Backing Up, Restoring & Rolling The Dice was the previous entry in this blog.

re: Where’s Bill? is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.