Application doesn't quit

  • Thread starter Thread starter Maziar Aflatoun
  • Start date Start date
M

Maziar Aflatoun

Hi everyone,

I'm writing an application that needs to quit when it encouters an error.
However, Application.Exit() doesn't do anything here. Does anyone know why?

public bool timerenabled
{
get
{
bool timerenabled;
ManageXML XMLSettingFile = new ManageXML();
try
{
timerenabled =
Convert.ToBoolean(XMLSettingFile.ReadElementValue("timerenabled"));
return timerenabled;
}
catch (System.Xml.XmlException eXML)
{
timerMonitor.Stop();
MessageBox.Show("Please check your setting.xml file and rerun the
application. Application now closing.\r\n" + eXML.Message );
Application.Exit();
}
return false;
}
}

Thank you
Maziar A.
 
Maziar,

Application.Exit should work in this context though. However, you are
calling this from within a timer callback. Is this a windows forms timer,
or a timer from the timers namespace? It might be possible (I am not sure)
that the call to Applciation.Exit requires the call to be made on the UI
thread.

Hope this helps.
 
Back
Top