internal static async Task <MySqlDataReader> CreateAsync(MySqlCommand command, CommandBehavior behavior, IOBehavior ioBehavior) { var dataReader = new MySqlDataReader(command, behavior); command.Connection.SetActiveReader(dataReader); try { await dataReader.ReadFirstResultSetAsync(ioBehavior).ConfigureAwait(false); if (command.Connection.BufferResultSets) { while (await dataReader.BufferNextResultAsync(ioBehavior, CancellationToken.None).ConfigureAwait(false) != null) { } } return(dataReader); } catch (Exception) { dataReader.Dispose(); throw; } finally { if (command.Connection.BufferResultSets) { command.Connection.FinishQuerying(); } } }