The blog of Eric Sibly; focusing on mountain biking, .NET development for the Desktop, Smartphone and PocketPC.

Friday, December 03, 2004

.NET 2.0 BackgroundWorker...

I think it is fantastic that there is greater support in the framework for performing asynchronous programming so we can create more responsive applications that do not annoyingly lock the UI for a period of time; and also provide the means for the user to cancel if they are tired of waiting. As good as the BackgroundWorker is I do not think it goes far enough.

It does not support a true thread cancel (Thread.Abort). Basically you have to implement the logic to check whether a cancel has been issued and then code to complete the cancel. Which is fine where you control the code being invoked async; what happens where you want to call a long running component that you don’t own – there is no way to cancel – therefore it could still run for a very long time. From what I can see you can not get to the Thread of the BackgroundWorker to cancel if required either. So although I think it is ok, I want more flexibility to cancel the thread there and now. I would like to say Cancel and if not cancelled in a nice fashion in n milliseconds – then go ahead and really cancel the thread.

0 Comments:

Post a Comment

<< Home