public override void Close()
{
if(State != ConnectionState.Closed)
{
var logger = LoggerManager.GetLogger("CqlSharp.CqlConnection.Close");
try
{
//wait until open is finished (may return immediatly)
_openTask.Wait();
}
catch(Exception ex)
{
logger.LogVerbose("Closing connection that was not opened correctly: ", ex);
}
//return connection if any
if(_connection != null)
{
Cluster.ConnectionStrategy.ReturnConnection(_connection, ConnectionScope.Connection);
_connection = null;
}
//clear cluster
_cluster = null;
//clear database
_database = string.Empty;
//clear open task, such that open can be run again
_openTask = null;
}
}