Hi,
I am quite new to .net programming, and I am currently programming something that uses windows forms + mysql to maintain something.
When I call Application.Exit() on a certain form , the program exits
but it crashes and comes up with microsoft error message box.
And the details say that it has semaphorefull.
I have tried to catch the exception and do nothing to handle it so it doesn't come up with error message but its not working.
The basic setup of the the program is that I have a mainform, and there is a button which opens up the other form.
this is the code to bring the new form :
And this is the exit event handler method
As you can see there is nothing special and I use the same code on the main form, which works fine on it.
Can you help me with this problem?
Thanks a lot in advance.
Regards,
JH
I am quite new to .net programming, and I am currently programming something that uses windows forms + mysql to maintain something.
When I call Application.Exit() on a certain form , the program exits
but it crashes and comes up with microsoft error message box.
And the details say that it has semaphorefull.
I have tried to catch the exception and do nothing to handle it so it doesn't come up with error message but its not working.
The basic setup of the the program is that I have a mainform, and there is a button which opens up the other form.
this is the code to bring the new form :
C#:
private void btnAccounts_Click(object sender, EventArgs e)
{
frmManageAccounts manageAccountsForm = new frmManageAccounts(username,
dbName, dbHost, password, dbType, dbInstance, permission);
this.Hide();
manageAccountsForm.Show();
conn.Close();
cmd = null;
this.Close();
this.Dispose();
GC.Collect();
}
And this is the exit event handler method
C#:
private void btnExit_Click(object sender, EventArgs e)
{
try
{
System.Windows.Forms.DialogResult result =
MessageBox.Show("Are you sure to exit?", "Closing Application",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button2);
if (result == System.Windows.Forms.DialogResult.OK)
{
closeFlag = true;
Application.Exit();
}
}
catch (Exception btnExit_Click_E)
{
MessageBox.Show(btnExit_Click_E.StackTrace);
}
}
Can you help me with this problem?
Thanks a lot in advance.
Regards,
JH
Last edited by a moderator: