statusbar.cs
On load of StatusBar form,i am calling the backgroundWorker1.In backgroundWorker1.DoWork i am calling the Login(Username, Password); function which is also in the same statusbar.cs file.
private void StatusBar_Load(object sender, EventArgs e)
{
backgroundWorker1.RunWorkerCompleted += (o, args) =>
{
Close();
};
backgroundWorker1.DoWork +=
(o, args) =>
{
Login(Username, Password);
};
backgroundWorker1.RunWorkerAsync();
}
Login(Username, Password)
{
if(Authenticated)
{
MessageBox.Show("Success");
//do some process
}
else
{
MessageBox.Show("Failed...");
return;
}
}
My problem is progress bar is loading correctly.It is showing until i close the Messagebox.Once the OK button in messagebox is clicked the progress bar disappear.I need to hide the progress bar once the messagebox loads/shows.I tried putting backgroundWorker1.CancelAsync(); before the messagebox not worked for me.
I need to close the progress bar once the message box appear.Is it possible to terminate the backgroundworker1 forcibly.