Application doesn't quit

  • Thread starter Maziar Aflatoun
  • 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.
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top