R
RockDale
Hi, there
How can I prevent the user close my form when my backend thread have
not finished the process? Well, I guess using source code is more clear
to describe my question
I have a form and I am using a work thread to get street list from sql
ce database.
private void Form_Load(object sender, System.EventArgs e)
{
DoThreading();
}
public void DoThreading()
{
Thread thread = new Thread(new ThreadStart this.GetStreetData));
thread.Start();
Application.DoEvents();
}
public void GetStreetData()
{
//doing database stuff
this.lblDataCache.Invoke (new EventHandler(WorkerUpdate));
}
public void WorkerUpdate(object sender, EventArgs e)
{
this.lblStatus.Text = "get street data successful!";
}
My question is, I want to prevent the user close this form before the
thread execution finished. Because I will open second form after this
form closed. And in the second form I will open sql ce connection to do
some data retrieve. If the thread still runing, I will get error as the
sql ce does not support multiple connections open at a same time.
Is there a solution or I am on the wrong direction?
Thanks a lot
-Rockdale
How can I prevent the user close my form when my backend thread have
not finished the process? Well, I guess using source code is more clear
to describe my question
I have a form and I am using a work thread to get street list from sql
ce database.
private void Form_Load(object sender, System.EventArgs e)
{
DoThreading();
}
public void DoThreading()
{
Thread thread = new Thread(new ThreadStart this.GetStreetData));
thread.Start();
Application.DoEvents();
}
public void GetStreetData()
{
//doing database stuff
this.lblDataCache.Invoke (new EventHandler(WorkerUpdate));
}
public void WorkerUpdate(object sender, EventArgs e)
{
this.lblStatus.Text = "get street data successful!";
}
My question is, I want to prevent the user close this form before the
thread execution finished. Because I will open second form after this
form closed. And in the second form I will open sql ce connection to do
some data retrieve. If the thread still runing, I will get error as the
sql ce does not support multiple connections open at a same time.
Is there a solution or I am on the wrong direction?
Thanks a lot
-Rockdale