Welcome to MSDN Blogs Sign in | Join | Help

A little fun with threading and VB.NET

I put together a little demo that shows how to do simple multithreaded code in VB.NET. Rather than bury a simple demo with synchronization to the nines, I'll tell you to just accept this as an learning sample of how to use the thread pool and how to kick off a new OS thread. It does not imply any best practices. You should synchronize your multithreaded code as appropriate. This sample is just meant to show people the basic mechanics of multithreading with VB.NET. Thought it was interesting, so I decided to put it up here.

Also, the MessageBoxes are simply in place to give me a cheap block on a thread. Uncomment the message box in DoFileSearch to see it. In production code, you should not touch UI from a worker thread. Rather, use a WinForm's Invoke method to push the work request back onto the UI thread that created it. You'll see an example of this in the code...

Also, the program searches for a file in a directory. obviously, you'll want to choose a file and directory that are actually on your machine ;-)

http://www.aggelos.com/demos/Threading-VBDemo.zip

This posting is provided "AS IS" with no warranties, and confers no rights.

Published Friday, January 30, 2004 5:18 PM by dougturn
Filed under:

Comments

# re: A little fun with threading and VB.NET

It was good talking to you at the DevDays. Say hi to the luminaries.
Friday, March 19, 2004 9:17 AM by Dimitri Glazkov

# re: A little fun with threading and VB.NET

Nice sample.
I have been looking for a real world sample for .net Threading. All samples I had come across involved some kind of Console.WriteLine.
This sample makes it much easier to understand.
Thanks
Ravi
Tuesday, December 20, 2005 11:26 PM by Ravi
New Comments to this post are disabled
 
Page view tracker