Mahesh Yadav
asked on
Abort the current thread and redirect to another page : windows application
I am working on a windows application in which i had created two new threads, one is for progress bar and another is for extracting data from db. What i want is when the second thread is completed, it will terminate the first thread and autoredirect the page to another page. I am able to redirect to another page but as the threads are running it returns back to first page.
Here is my code:
private void LoadingForm_Load(object sender, EventArgs e)
{
Thread thread = new Thread(new ThreadStart(loadbar));
CheckForIllegalCrossThread Calls = false;
thread.Start();
Thread Customerthread = new Thread(new ThreadStart(GetCustomerDet ails));
Customerthread.Start();
}
private void loadbar()
{
progressBar1.Minimum = 1;
progressBar1.Maximum = 25;
progressBar1.Value = 1;
progressBar1.Step = 1;
for (int i = 0; i < 25; i++)
{
System.Threading.Thread.Sl eep(500);
progressBar1.PerformStep() ;
}
CustomerList cList = new CustomerList(ListValues);
cList.Show();
}
private void GetCustomerDetails()
{
// Code to get data from db.
}
Here the control goes to customerlist page but returns back after running its constructor.
Please advice.
Here is my code:
private void LoadingForm_Load(object sender, EventArgs e)
{
Thread thread = new Thread(new ThreadStart(loadbar));
CheckForIllegalCrossThread
thread.Start();
Thread Customerthread = new Thread(new ThreadStart(GetCustomerDet
Customerthread.Start();
}
private void loadbar()
{
progressBar1.Minimum = 1;
progressBar1.Maximum = 25;
progressBar1.Value = 1;
progressBar1.Step = 1;
for (int i = 0; i < 25; i++)
{
System.Threading.Thread.Sl
progressBar1.PerformStep()
}
CustomerList cList = new CustomerList(ListValues);
cList.Show();
}
private void GetCustomerDetails()
{
// Code to get data from db.
}
Here the control goes to customerlist page but returns back after running its constructor.
Please advice.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oups... switch newThread on last line for ThreadNameHere
ASKER
The given solution is not specifying the exact solution for the question asked.