Friday, April 13, 2007

ATA (Another Threading Article ;) - VB.Net Threading Wrapper/Factory Code Project Article

Code Project - Threading Wrapper Classes in VB

"Oh my god not another threading article", I hear you cry. "Isn't there enough threading articles on CodeProject already!?"

"Er, no," is my answer (now that's a surprise isn't it).

So why bother? If you want a good example of a thread pooling solution then read the C# article by Ami Bar (Smart Thread Pool), and there are lots of other good threading articles throughout CodeProject, so why?

Well, most of these articles are written for C# (indeed most of all the articles here seem to be written for C# at the moment) and I wanted to see a VB solution.

What does this set of wrapper classes do? Well they are a group of classes that come together to allow the developer to create their own class which performs a task and is inherited from a previously created base class. Each instance of this developer created class runs in its own thread and data is fed to it, one data item at a time (as a passed parameter) from a single or even multiple input queue(s).

The class then outputs any resultant data via multiple output queues. These queues in turn become input queues for other task instances. What this means is that you can quite easily create a basic workflow. A piece of data moves from one thread, which performs a unique job or task, to a second thread, then perhaps to a third thread etc. All inter-thread movement is made by use of queues.

In the samples provided I have created such a "workflow". One task identifies a list of files in a folder, and the description of each file is then sent to a separate thread which zips the file. A description of the zipped file is then sent to another thread which encrypts the file.

..."

I've been keeping my eyes open for an article like this... I'm working on a multithreaded (well beyond BackgroundWorker) project at work and am looking for different implementation ideas. Given that I'm already using queues, this one fits quite well...

Update #1 4/16/2007 @ 10:46AM PDT:
Updated the formatting (adding line feeds) of the quoted text above...

No comments:

Post a Comment

NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...

ALL comments are moderated. I will review every comment before it will appear on the blog.

Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...

I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...

Please see my comment policy for more information if you are interested.

Thanks,
Greg

PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...