views:

56

answers:

2

I have a background task that imports files into a database. I want the user to see what is currently happening (collecting files/ importing files), which file is currently processed and how far the task has progressed. How can I do this in an easy way? The interaction between Model and Controller is so close, that I could almost put the importing code into the window's code file and change the progress bar value etc. directly. What do you think? How would you solve this problem?

+6  A: 

Use a BackgroundWorker, it's perfect for this task. It can notify the UI of current progress using the ReportProgress method, which raises the ProgressChanged event on the UI thread (which means you don't have to worry about cross-thread calls and Invoke)

Thomas Levesque
BackgroundWorker is a fantastic tool for basic threading and reporting. +1
Josh Smeaton
A: 

Progress bars can be misleading in a lot of cases so I suggest you be careful setting expectations.

If you do end up showing progress as a percentage of some sort do account for varying load times depending on file size.

Raj More