multi threaded status query

N

Newbie

Hi,

I have an application that will have a number of threads created to perform
data manipulation tasks in the backround worker class.

Looking through some of the documentation on how to do this, it seems that
the background worker class is able to only really giv eback data when the
thread completes.

What I a want to do is every second(using a timer event) get back the %
complete of the data manipulation, so that the user can see the progress of
each of the tasks going on.

The only way I can think to do this is have the thread write a value to the
disk, and then the primary applicaiton thread reads this file every second
to get the value. Seems a bit wierd to do this.

Is there a better way to do this ?

Hope it all made sense ...
 
C

Cor Ligthert[MVP]

Hi,

I use almost forerver for this problem the queu class (or generic queu class
if that is better in that case).

Deque it as the cound is not zero and if not set a timer if this is changed
is probably the easiest, however you can as well raise an event in your
subthreads if you have enqued the queu.

Don't forget to synclock while you are enqueing and dequeing

http://msdn.microsoft.com/en-us/library/system.collections.queue.aspx

Cor
 
J

Jack Jackson

Hi,

I have an application that will have a number of threads created to perform
data manipulation tasks in the backround worker class.

Looking through some of the documentation on how to do this, it seems that
the background worker class is able to only really giv eback data when the
thread completes.

What I a want to do is every second(using a timer event) get back the %
complete of the data manipulation, so that the user can see the progress of
each of the tasks going on.

The only way I can think to do this is have the thread write a value to the
disk, and then the primary applicaiton thread reads this file every second
to get the value. Seems a bit wierd to do this.

Is there a better way to do this ?

Hope it all made sense ...

BackgroundWorker has a ProgressChanged event just for this.
 
K

kimiraikkonen

BackgroundWorker has a ProgressChanged event just for this.

Additionaly to use ProgressChanged event of BackgroundWorker, as you
know, it's required to set "WorkerReportsProgress" property to True
then call ReportProgress method.

Onur Güzel
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top