MySql.Data.MySqlClient.MySqlConnection.SetCommandTimeout C# (CSharp) Method

SetCommandTimeout() private method

Sets query timeout. If timeout has been set prior and not yet cleared ClearCommandTimeout(), it has no effect.
private SetCommandTimeout ( int value ) : bool
value int timeout in seconds
return bool
        internal bool SetCommandTimeout(int value)
        {
            if (!hasBeenOpen)
                // Connection timeout is handled by driver
                return false;

            if (commandTimeout != 0)
                // someone is trying to set a timeout while command is already
                // running. It could be for example recursive call to ExecuteReader
                // Ignore the request, as only top-level (non-recursive commands)
                // can set timeouts.
                return false;

            if (driver == null)
                return false;

            commandTimeout = value;
            driver.ResetTimeout(commandTimeout * 1000);
            return true;
        }

Usage Example

Exemplo n.º 1
0
 public CommandTimer(MySqlConnection connection, int timeout)
 {
     _connection = connection;
     if (connection != null)
     {
         _timeoutSet = connection.SetCommandTimeout(timeout);
     }
 }
All Usage Examples Of MySql.Data.MySqlClient.MySqlConnection::SetCommandTimeout