The await is what allows a method to run asynchronously. The async allows you to use the await keyword in this method and helps with return control.
Until await , the method will execute synchronously.
So, all this is done synchronously. It will not return anything or move the method until it is complete.
public async Task<IEnumerable<Widget>> ReadAllAsync( System.Data.IDbConnection databaseConnection, System.Data.IDbTransaction databaseTransaction) { var commandText = "SELECT WidgetId, Name FROM Widget";
Dropping on DbCommand , which are already being executed in most of the IDbCommand implementations, then casting will be performed on DbCommand and adding the wait, for example.
var dbCommand = (DbCommand) command; using (var dataReader = await dbCommand.ExecuteReaderAsync()) { while (await dataReader.ReadAsync()) {
or create a separate task
public async Task MyAsyncMethod() {
This way - the program will continue, waiting for a return from this method, instead of blocking the user interface and everything else.
source share