CqlSharp.CqlConnection.Dispose C# (CSharp) Метод

Dispose() защищенный Метод

Releases the unmanaged resources used by the T:System.ComponentModel.Component and optionally releases the managed resources.
protected Dispose ( bool disposing ) : void
disposing bool /// true to release both managed and unmanaged resources; false to release only unmanaged /// resources. ///
Результат void
        protected override void Dispose(bool disposing)
        {
            if(!_disposed && disposing)
            {
                if(State == ConnectionState.Connecting)
                {
                    try
                    {
                        //wait until open is finished (may return immediatly)
                        _openTask.Wait();
                    }
                        // ReSharper disable EmptyGeneralCatchClause
                    catch
                    {
                        //ignore here
                    }
                    // ReSharper restore EmptyGeneralCatchClause
                }

                if(State == ConnectionState.Open)
                {
                    //return connection if any
                    if(_connection != null)
                    {
                        Cluster.ConnectionStrategy.ReturnConnection(_connection, ConnectionScope.Connection);
                        _connection = null;
                    }
                }

                //clear cluster
                _cluster = null;

                //clear database
                _database = string.Empty;

                //dispose any remaining cancel tokens
                if(_userCancelTokenSource != null)
                {
                    _userCancelTokenSource.Dispose();
                    _userCancelTokenSource = null;
                }

                if(_openCancellationTokenSource != null)
                {
                    _openCancellationTokenSource.Dispose();
                    _openCancellationTokenSource = null;
                }

                _disposed = true;
            }
            base.Dispose(disposing);
        }
    }