Exit application when exception caught on BeginConnect
<p>I am sorry if i do/did something wrong here, this is my first question in this website.</p>

<p>I am trying to completly exit my application (process) when a BeginConnect throws an error (mainly SocketException).</p>

<p>My code right now :</p>

<pre><code>try
{
     Socket.BeginConnect(new IPEndPoint(IPAddress.Parse(ip), port), new AsyncCallback(ConnectionCallBack), Socket);
}
catch (System.Exception ex)
{
     OnError(new ErrorEventArgs(ex));
}
</code></pre>

<p>The ErrorEvent fires, and this is where i try to exit my application :</p>

<pre><code>if (e.Ex is SocketException)
{
     MessageBox.Show(LanguageManager.GetText("Erreur1"));
     client.Dispose();
     Application.Exit();
}
</code></pre>

<p>But then, the debug mode is still running.. or if i try it without the debug mode, i find the process still there in the task manager.</p>

<p>Thanks for helping !</p>