c# app that close self on start if there's no internet connection
<pre><code>if(IsConnected() == false)
{
    Console.WriteLine("no connection");
    System.Windows.Forms.Application.Exit();
}

InitializeComponent();

...

public static bool IsConnected()
{
    System.Uri Url = new System.Uri("http://google.com");

    System.Net.WebRequest WebReq;
    System.Net.WebResponse Resp;
    WebReq = System.Net.WebRequest.Create(Url);            

    try
    {
        Resp = WebReq.GetResponse();
        Resp.Close();
        WebReq = null;
        return true;
    }

    catch
    {
        WebReq = null;
        return false;
    }
}
</code></pre>

<p>Here's part of code (c# .net 1.0) which check if there is connection or not and depending on that i want my app to close (exit)
I can see in console log that there is "no connection" but app keep running...
How to exit that app properly there?</p>
