Help with Threading on Winform
Posted on 2004-11-05
I have a Winform with an OK button. The button processes a long query. While the query is running I would like to run a progress bar via a timer to show something happening.
I had to run the long query in another thread so the progress bar would update. When the query ends and the form closes I get a null reference exception. I think it is because of a problem with my threading..
Enclosed is my code : Thanks in advance...
private void btnOK_Click(object sender, System.EventArgs e)
this.pictureBox.Visible = true;
this.timerProgress.Enabled = true;
this.progressBar.Visible = true;
this.progressBar.Minimum = 0;
this.progressBar.Maximum = 25; //or any other number
this.progressBar.Value = 0;
this.progressBar.Step = 1;
ThreadStart threadStart = new ThreadStart(FilterData);
m_WorkerThread = new Thread(threadStart);
private void FilterData()
// Long queries....................
ThreadFinished (this,new EventArgs());
private void Form1_ThreadFinished(object sender, EventArgs e)