views:

34

answers:

1

Hi

Firstly, I've never used threads, but have found lots of examples on the internet about their use but nothing that obviously answers my question.

I have a class that loads and manipulates a file(s). It is fairly CPU intensive so I intend to put it in its own thread so that the GUI remains responsive. However, I would also like to use a progress bar to indicate the current status of the file operations.

The question is, what is the best way of approaching this, i.e. How do I get my file class to tell the app where it's up to? Do I have to add thread specific code to my class? Or is there an interface I can implement? Or, am I approaching this all wrong. Additionally (sorry, another stupid question) I assume I need an indicator in my file class to tell the thread when it's finished?

I'm using VS2010 and intend to build the app with WPF (if that's relevant)

Thanks for any advice, Bob

+2  A: 

Since you are intending to use WPF, use a Dispatcher:

Build More Responsive Apps With The Dispatcher

(Otherwise, for Winforms use a BackgroundWorker)

Mitch Wheat