public static async Task <T> UseConnectionAsync <TConnection, T>(this ConnectionPoolUsage <TConnection> pool, Func <TConnection, Task <T> > user, CancellationToken token = default(CancellationToken)) { var retVal = default(T); await pool.UseConnectionAsync(async connection => retVal = await user(connection), token); return(retVal); }
public static async Task UseConnectionAsync <TConnection>(this ConnectionPoolUsage <TConnection> pool, Action <TConnection> executer, CancellationToken token = default(CancellationToken)) { await pool.UseConnectionAsync(connection => { executer(connection); return(TaskUtils.CompletedTask); }, token); }
public static async Task <T> UseConnectionAsync <TConnection, T>(this ConnectionPoolUsage <TConnection> pool, Func <TConnection, T> user, CancellationToken token = default(CancellationToken)) { var retVal = default(T); await pool.UseConnectionAsync(connection => { retVal = user(connection); return(TaskUtils.CompletedTask); }, token); return(retVal); }