Mea Culpa on CLR Async

Don Box's Spoutlet

Syndication

My last book made (at least) two statements that I now regret.
 
  1. Calling EndXXX on an IAsyncResult is optional.
  2. BeginInvoke is preferable to ThreadPool.QueueUserWorkItem.
 
On the former, the reality is that some implementations rely on the EndXXX call to clean up resources.  Sometimes you can get away with it, but in the general case you can't.
 
On the latter, the fact that materializing an IAsyncResult causes a Win32 event to be allocated makes it a tough sell compared to QUWI, especially now that lambdas/closures are so much more approachable in Whidbey.

Posted May 23 2005, 06:55 PM by don-box

Comments

Chris Sells wrote re: Mea Culpa on CLR Async
on 05-23-2005 3:10 PM
Agreed. If BackgroundWorker hadn't come along, I'd have ripped all the asynch delegate stuff out of the threading chapter of the winforms book and replaced it with QUWI.
Dilip wrote re: Mea Culpa on CLR Async
on 05-23-2005 6:56 PM

We ran into this problem quite a bit. We do a fair bit of fire-and-forget calls. After some profiling we discovered that our app leaked memory copiously with the private bytes staying at close to 50Meg sometimes. We are trying to modify the calls to call EndInvoke using Mike Woodring's DynamicInvoke shim.
Praveen R P wrote Essential .NET Modules and Assemblies
on 05-24-2005 12:47 AM
Hello Don,

In your book titled Essential .NET, you mention that modules are physical constructs and assemblies are logical constructs.

How are you justifying that assemblies are logical? I also happened to check with a couple of people from MS Bangalore, but was not able to get an answer
Martin Plante wrote re: Mea Culpa on CLR Async
on 05-24-2005 5:26 AM
Imagine all the customers who came back to us saying "Don Box says I don't need to call your EndXxx method. Your library is broken!". It was such a difficult task to tell them "Don is wrong", try to convince them, and live with the fact that I was going against one of my gurus.

"Don is wrong". The words still echo in my head when I try to sleep. It was a tough time... Thank you for that coming out... I think I'm gonna cry now...
Dmitriy Zaslavskiy wrote re: Mea Culpa on CLR Async
on 05-24-2005 1:40 PM
> BeginInvoke is preferable to ThreadPool.QueueUserWorkItem ... On the latter, the fact that materializing an IAsyncResult causes a Win32 event to be allocated makes it a tough sell compared to QUWI

Most implementations of IAsyncResult allocate event lazily and if you never ask for WaitHanlde will not allocate it at all.

BeginXXX will use different mechanism for remoting that will often result in better performance/resource utilization than QUWI.
Marco Russo wrote BeginInvoke e QueueUserWorkItem
on 05-26-2005 4:09 PM

Add a Comment

(required)  
(optional)
(required)  
Remember Me?