, SQLite ADO.NET(DbConnection
, DbCommand
) . Async
, , . , DbConnection.OpenAsync
:
public virtual Task OpenAsync(CancellationToken cancellationToken)
{
TaskCompletionSource<object> completionSource = new TaskCompletionSource<object>();
if (cancellationToken.IsCancellationRequested)
{
completionSource.SetCanceled();
}
else
{
try
{
this.Open();
completionSource.SetResult((object) null);
}
catch (Exception ex)
{
completionSource.SetException(ex);
}
}
return (Task) completionSource.Task;
}
, , .
Async
DbCommand
: TaskCompletionSource
, Task.FromResult
.
SQLiteCommand , - , . , () ExecuteReaderAsync
:
public virtual Task<SqliteDataReader> ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
return Task.FromResult<SqliteDataReader>(this.ExecuteReader(behavior));
}
- SqlConnection
SqlCommand
() , OpenAsync
ExecuteReaderAsync
, sql , .
, , , SQLite.
WPF, , , async\await, . Task.Run
.