VB.NET threading question

  • Thread starter Thread starter Glenn Dekhayser
  • Start date Start date
G

Glenn Dekhayser

Weird question, hopefully someone out there can help.

I am basically iterating through a list of files, using
QueueUserWorkItem to spawn a thread to process each file.

I am using a wrapper class around the processing logic as a way to set
parameters for the logic.

So I do the QueueUserWorkItem and the processing goes on its merry
way.

I want to know when the processing for each file is done- how do I
know (or how do I determine) when the processing for each is complete
so I can keep tabs on what's done and what's not??

Thanks in advance, anyone!

Glenn Dekhayser
 
Weird question, hopefully someone out there can help.

I am basically iterating through a list of files, using
QueueUserWorkItem to spawn a thread to process each file.

I am using a wrapper class around the processing logic as a way to set
parameters for the logic.

So I do the QueueUserWorkItem and the processing goes on its merry
way.

I want to know when the processing for each file is done- how do I
know (or how do I determine) when the processing for each is complete
so I can keep tabs on what's done and what's not??

Thanks in advance, anyone!

Glenn Dekhayser

I see one of two solutions here... Raise an event from the thread when
processing is completed, or use async delegates to do the processing.
 
Hi Glenn

Further to Tom's answer, if you are raising an event that you then handle in
your main thread, be aware that Windows controls are not thread-safe. If you
use the event to update the screen, e.g. a progress bar, you will need to
marshal the event back to the main thread before you update any controls.
Use InvokeRequired on the control in question to determine whether
marshalling is necessary, and if so use Invoke to pass a delegate to the
control which it then calls to do the update.

If you don't do this, your app may still appear to work, but it will stop,
and it won't be obvious why. Trust me, it is necessary.

HTH

Charles
 
Back
Top