public void Dispose() { Identifiers?.Dispose(); CumulativeIdentifiers?.Dispose(); _rIds?.Dispose(); _rCumulative?.Dispose(); _cmdCount?.Dispose(); _cmdCountCumulative?.Dispose(); }
public void GetCohortAsync(IDataAccessPoint[] accessPoints, int commandTimeout) { if (Identifiers != null) { throw new Exception("GetCohortAsync has already been called for this object"); } Identifiers = new DataTable(); IsExecuting = true; var server = GetServerToExecuteQueryOn(accessPoints); server.EnableAsync(); using (var con = server.GetConnection()) { con.Open(); _cmdCount = server.GetCommand(CountSQL, con); _cmdCount.CommandTimeout = commandTimeout; var identifiersReader = _cmdCount.ExecuteReaderAsync(_cancellationTokenSource.Token); identifiersReader.Wait(_cancellationTokenSource.Token); _rIds = identifiersReader.Result; Identifiers.Load(_rIds); _rIds.Close(); _rIds.Dispose(); Task <DbDataReader> cumulativeIdentifiersRead = null; //if there is cumulative SQL happening if (!string.IsNullOrWhiteSpace(CumulativeSQL)) { CumulativeIdentifiers = new DataTable(); var cmdCountCumulative = server.GetCommand(CumulativeSQL, con); cmdCountCumulative.CommandTimeout = commandTimeout; cumulativeIdentifiersRead = cmdCountCumulative.ExecuteReaderAsync(_cancellationTokenSource.Token); } if (cumulativeIdentifiersRead != null) { cumulativeIdentifiersRead.Wait(_cancellationTokenSource.Token); _rCumulative = cumulativeIdentifiersRead.Result; CumulativeIdentifiers.Load(_rCumulative); _rCumulative.Close(); _rCumulative.Dispose(); } IsExecuting = false; } }
public void Dispose() { if (Identifiers != null) { Identifiers.Dispose(); } if (CumulativeIdentifiers != null) { CumulativeIdentifiers.Dispose(); } if (_rIds != null) { _rIds.Dispose(); } if (_rCumulative != null) { _rCumulative.Dispose(); } }