Hi,
I'm trying to exit from an application if an exception occurs, but for some reason neither
Me.Close not Application.Exit appear to be doing anything. I even tried ExitThread, which I am a bit wary of without doing a bit more reading up on.
Code below:
Private Sub ManagerForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim bolReadConfigFile As Boolean = True
Do While bolReadConfigFile
Try
ConfigurationHandler.ReadConfigData()
bolReadConfigFile = False
Catch exCH As ConfigurationHandlerException
Dim objResult As DialogResult
objResult = MessageBox.Show(Error, ConfigurationError,
MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2)
If (objResult = DialogResult.Cancel) Then
'Here I have tried
Me.Close()
Application.Exit()
Application.ExitThread()
End If
End Try
Loop
Try
'Rest of Code....
Catch ex As Exception
MessageBox.Show(FailedToStart, FailedToStart, MessageBoxButtons.OK, _
MessageBoxIcon.Information)
Me.Close()
End Try
End Sub
Any ideas/suggestion greatly appreciated!
Eric.

Exiting application with Me.Close and Application.Exit not working.
Oranso
Got it working by placing the Do..While loop within the overall try..catch, thowing an exception if the dialogue box reult is cancel, and doing the Me.Close when caught.
Private Sub ManagerForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim bolReadConfigFile As Boolean = True
Try
Do While bolReadConfigFile
Try
ConfigurationHandler.ReadConfigData()
bolReadConfigFile = False
Catch exCH As ConfigurationHandlerException
Dim objResult As DialogResult
objResult = MessageBox.Show(Error, ConfigurationError,
MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2)
If (objResult = DialogResult.Cancel) Then
Throw new ApplicationException("Byeee!!!")
End If
End Try
Loop
'Rest of Code....
Catch exAE As ApplicationException
Me.Close()
End Try
Catch ex As Exception
MessageBox.Show(FailedToStart, FailedToStart, MessageBoxButtons.OK, _
MessageBoxIcon.Information)
Me.Close()
End Try
End Sub
I've no idea why it would not work within the other code blokes though, any ideas
Cheers!
Eric.