473,395 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

VB.NET threading question

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
Nov 20 '05 #1
4 1594
On 2004-04-08, Glenn Dekhayser <gd********@voyantinc.com> wrote:
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.

--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
"Yes, it's the right planet, all right, " he said again.
"Right planet, wrong universe. "
Nov 20 '05 #2
On 2004-04-08, Glenn Dekhayser <gd********@voyantinc.com> wrote:
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.

--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
"Yes, it's the right planet, all right, " he said again.
"Right planet, wrong universe. "
Nov 20 '05 #3
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
"Glenn Dekhayser" <gd********@voyantinc.com> wrote in message
news:ce**************************@posting.google.c om...
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

Nov 20 '05 #4
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
"Glenn Dekhayser" <gd********@voyantinc.com> wrote in message
news:ce**************************@posting.google.c om...
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

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

65
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the...
19
by: Jane Austine | last post by:
As far as I know python's threading module models after Java's. However, I can't find something equivalent to Java's interrupt and isInterrupted methods, along with InterruptedException....
3
by: David Harrison | last post by:
I am working on an application on Mac OS X that calls out to python via PyImport_ImportModule(). I find that if the imported module creates and starts a python thread, the thread seems to be...
4
by: Antal Rutz | last post by:
Hi, All! I'm new to threading. I have some design questions: Task: I collect data and store them in an RDBMS (mysql or pgsql) The question is how to do that with threading? The...
6
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service...
7
by: Anthony Nystrom | last post by:
What is the correct way to stop a thread? abort? sleep? Will it start up again... Just curious... If the thread is enabling a form, if the form is disposed is the thread as well? Thanks, ...
4
by: Bob | last post by:
- For cleanup, is it sufficient to set a Thread to Nothing after it's done? - It is OK to pass objects out of the thread? (dumb question maybe but I want to be sure) - What's the best way to...
4
by: DBC User | last post by:
I have a background process which reads a table to see if there are any pending requests. If there are any, then it will start a worker thread (only 10 allowed at a time) and executes a method. In...
4
by: Steven | last post by:
I am taking an "advanced" VB.Net course via web at a state university toward an information science degree. This is my second VB class and I am kind of disappointed in it. This week we covered...
19
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.