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

مشاهدة النسخة كاملة : Re: Backgroundworker Thread Issue



C# Programming
07-21-2012, 03:25 AM
I have a winform where I dropped Backgroundworker control and running some loop in DoWork event handle. At the same time I am also within DoWork, I am calling "ReportProgress" method to update my ProgressBar. I thought as my work is going on within DoWork, I can click on other areas of Form and basically since its BackgroundWorker, my other GUI should be responsive but my whole Machine is frozen till "DoWork" finishes. What I am doing wrong? Here is code from :
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { //Do Intensive Work ArgumentClass backGroundCls = e.Argument as ArgumentClass; //Now you can do whatever you want to do with passed arguments int ctr=0; do { ctr++; backgroundWorker1.ReportProgress(ctr); } while (ctr < 10000000);Favourite quote:

In youth we learn, In age we understand.