Threads example

Hi All,

I have a program with a timer that checks a folder with xml files. This folder my contain 3 type of files. I want to work with threads to process each type file with its own thread. The method processing the files has one folderitem parameter. Could you help me on the way with a proper example?


Have you taken a look at the Example on how to update UI from within threads? I would modify the example to fit your needs.

Hi Bob,

I have found that example but did not understand the functionality of it. If you can provide me with an altered example i would appreciate that.


Sorry, but no. I don’t have the time, plus I think it’s one of those basic sorts of skills you’ll need to spend some time on to figure it out.

Thanks Bob,

Its not that I don’t understand threads. I already used them with a web application using a process button.
My current application runs as a service in a windows environment and the initial method receives a folderitem.
I’m not able to find an example that triggers a method using threads with multiple parameters.

Threads are classes. Nothing stopping you from subleasing a thread to get the right data into it.

A simple workaround would be to use a module with properties. Set the properties from the main thread, and your processing thread can access those properties just fine.

You can also create a Constructor for the thread that takes the parameters that in turn puts them into properties that are in the thread.

Dim th as New yourThread(param1, param2)

Or have I gotten this all wrong? :slight_smile:
I’m on vacation so the brain thingy isn’t really the way it should.

Subclass the thread and add a new run event that accepts parameters. Store the parameters and call the real Run method.

Either a constructor or a Run method will work.
I’d make a private zero param constructor and one with parameters.
I’d prefer a constructor since you could mistakenly call the Run method with no parameters and it might not be obvious why things don’t work as expected.

Thanks Guys,

Sounds all goods. I will give it a go.