Hi there,
I have an application that processes a long html file and breaks it into parts. in the process of this it has to create an entry in a database for every part and do some other stuff, blah blah... the point is that it takes about a minute and a half all said and done - the program looks like it isn't responding and the call I make just before I start the processing to disable the button doesn't always seem to work.
The point of all this is that I looked into a background worker to solve the problem. I think I implemented it right but it doesn't seem to be doing the job - it seems to act just like it did before - i.e button doesn't disable, the label with the current line number doesn't update... I am wondering if I did something wrong. this is how I implemented it.
I create the background worker and instead of calling the function from the button I call backgroundWorker.RunWorkerAsync() from the button. my do work function and the others (there is no cancel) look like this.
What am I missing? The interface still remains unresponsive and doesn't updatet...Code:private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { htmlFileCreater(); } private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { lblFileToLoad.Text = "File upload complete"; } private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) { lblProgress.Text = e.ProgressPercentage.ToString(); //progressBar.Value = e.ProgressPercentage; }
OK - Thanks!




Reply With Quote