المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : User Feedback while main thread is busy



C# Programming
11-26-2009, 06:51 PM
I want simple way to give feedback to the user while the main thread is busy.

In the main thread I want something like


ProgressBox prog = new ProgressBox();
prog.Show();
for ( int i=0 ; ; i++ ) {
...
prog.NumProcessed = i;
}
prog.Close();


The problem is that the ProgressBox freezes after a couple of seconds and updates only once after the loop is finished.

Ok, it has something to do with Threading. However, I have tried to find a solution, but all seems to come down to performing the work(the for loop here) in another thread.
But this is not what I want. I want the work to be performed in the main thread for simplicity if the main thread has to wait anyway!
The ProgressBox can run in separate thread, I could not care less. But I need a generic solution for feedback to the user instead of a "looks like a crash".

I might just be too stupid, but anyone already stumbled across a solution to this.

regards Rolf