When is DbConnection.StateChange called? : <p>I have the following code:</p>

<pre><code>   class Program
{
    static void Main()
    {
        var connection = new SqlConnection("myConnectionString");
        connection.Open();
        connection.StateChange += HandleSqlConnectionDrop;
        Console.WriteLine("Hi");
        Console.ReadLine();
    }

    private static void HandleSqlConnectionDrop(object connection, StateChangeEventArgs args)
    {
        Console.WriteLine("DB change detected");
    }
}
</code></pre>

<p>I start the above code while the SQL server instance is running.  I then proceed to execute</p>

<pre><code>SHUTDOWN WITH NOWAIT;
</code></pre>

<p>on the sql server instance that the program is connected to.  I then observer the SQL server service stopping.  However, I never see the "DB change detected" message in the output.  Why is this?</p>

<p><strong>Aside:</strong> I will see the StateChange handler get called if I then attempt to perform an operation on the SQL connection, but never before hand.  Is there a way this behavior can be changed?</p>
