I know you can set the Connection Timeout parameter on the ConnectionString, however, it sets the minimum timeout time and not the maximum.
My application works connected to a remote database and it needs to gray out the screen and wait for the connection to come back if it had been lost. I already do this fine, but sometimes when the connection is lost it takes more than 30 seconds to it realize the connection is lost, even with a minimum Connetion Timeout parameter value.
I detect the connection is lost because I have a thread doing a polling on the database every 0.5 second, and I wait for it to throw the "A network-related or instance-specific error occurred while establishing a connection to SQL Server" exception.
I want to know if there is a nice way of setting a maximum timeout or other alternative to it detect faster that the connection is lost.
Edit: I didn't know that also existed the CommandTimeout. It doesn't work perfectly but works better. It have to be set on every new DataContext object but it's fine. I set to a value X and it seems to always take X + 5 seconds to throw a Timeout exception.
Open()call. It doesn't apply to commands at all. The CommandTimeout applies to theExecuteorExecuteScalarcalls. It doesn't apply to connections at all.