QueuedBackgroundWorker Component

I've uploaded the code I was referring to previously to my sample code page.  You can find it here.  The implementation of the QueuedBackgroundWorker class is heavily commented (both the ConstructorInfo-abusing as well as nice & legal variations), but I didn't have much chance to comment the sample application that demonstrates the component's use, so you'll have to spelunk around a bit.

But the basic idea is that it's a Windows Forms app that lets you select one or more text files to view with a single click.  Information about each file selected is queued up to the component, which calls the app's DoWork event handler sequentially (along with the corresponding ProgressChanged and RunWorkerCompleted notifications).  The DoWork handler uses a custom Stream class named SlowStream to actually read the text files from disk, so the I/O is artificially very slow.  A checkbox allows you to toggle whether or not the QueuedBackgroundWorker class is used to read all of the selected files or not.  If not, the UI remains frozen until all files have been read.  A cancel button lets you cancel all pending operations in one go.

As mentioned in the disclaimer of my previous post, there are two variations of the QueuedBackgroundWorker provided in the zip; one that uses ConstructorInfo and one that doesn't.


Posted Oct 25 2005, 02:16 PM by mike-woodring

Comments

Christopher Steen wrote Link Listing - October 26, 2005
on 10-26-2005 8:18 PM
"ASP.NET 2.0 Web Server Here" Shell
Extension [Via: Robert
McLaws ]
Advanced Page Settings: DotNetNuke...
John Wood wrote re: QueuedBackgroundWorker Component
on 11-13-2005 5:47 PM
That's neat.. as an alternative to using the DoWork / Progress / Complete events, could you take a look at a helper class I've written that allows you to safely call any UI method cross-thread, you may find it interesting.

http://dotnetjunkies.com/WebLog/johnwood/archive/2005/08/31/132267.aspx

Add a Comment

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