M
Mark Stevens
I am having a problem aborting an application during startup. The
Application.Exit() function is not terminating the application
correctly.
The app checks the registry to see if it has been configured (i.e.
from a previous run). If it has not then it displays the file open
dialog to locate the application database. If the database is invalid
then a message box is displayed and the user is asked if they want to
try selecting another file.
Now this is where the problem starts. If the app is not configured
and the user selects Cancel in the message box then I want the app to
exit. However, it does not. Debugging the code shows that the app
gets through to the Application.Exit() but it does not exit.
I have Googled and checked the knowledge base and can find nothing
that helps.
The logic is as follows:
private void frmMain_Load(object sender, EventArgs e)
{
try
{
// Do some form initialisation and read config from registry
if (!configured) // Values from registry.
{
bool retrying = true;
while (retrying)
{
if (dlgOpenFile.ShowDialog() == DialogResult.OK)
{
// Do some check etc.
}
else
{
if (DialogResult.No == MessageBox.Show("Retry"))
{
Close();
Application.Exit();
}
}
}
}
}
catch
{
// Process the error.
}
}
Thanks in advance,
Mark
--
|\ _,,,---,,_ A picture used to be worth a
ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
|,4- ) )-,_. ,\ ( `'-' came television!
'---''(_/--' `-'\_)
Mark Stevens www.thepcsite.co.uk
Application.Exit() function is not terminating the application
correctly.
The app checks the registry to see if it has been configured (i.e.
from a previous run). If it has not then it displays the file open
dialog to locate the application database. If the database is invalid
then a message box is displayed and the user is asked if they want to
try selecting another file.
Now this is where the problem starts. If the app is not configured
and the user selects Cancel in the message box then I want the app to
exit. However, it does not. Debugging the code shows that the app
gets through to the Application.Exit() but it does not exit.
I have Googled and checked the knowledge base and can find nothing
that helps.
The logic is as follows:
private void frmMain_Load(object sender, EventArgs e)
{
try
{
// Do some form initialisation and read config from registry
if (!configured) // Values from registry.
{
bool retrying = true;
while (retrying)
{
if (dlgOpenFile.ShowDialog() == DialogResult.OK)
{
// Do some check etc.
}
else
{
if (DialogResult.No == MessageBox.Show("Retry"))
{
Close();
Application.Exit();
}
}
}
}
}
catch
{
// Process the error.
}
}
Thanks in advance,
Mark
--
|\ _,,,---,,_ A picture used to be worth a
ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
|,4- ) )-,_. ,\ ( `'-' came television!
'---''(_/--' `-'\_)
Mark Stevens www.thepcsite.co.uk