ConfigureAwait (false) with ADC.Net SQLConnection object

I started using ConfigureAwait(false)with all async sql objects.

connection.OpenAsync().ConfigureAwait(false);
cmd.ExecuteNonQueryAsync().ConfigureAwait(false);

But I'm worried if there will be any implications for this approach?

Since this will be done in the thread pool, which is the separate thread from which it originated, I am not sure of the consequences if we do not start it in the same thread.

Our application is a wcf service that will process 1000 records in parallel.

If someone helps identify business scenarios where this could be a problem that would be helpful.

thank

+4
source share
1 answer

, , ConfigureAwait(false) - , . . , (, winforms, MVC ..) , ConfigureAwait(false). :

async Task SomeUXCodeAsync() {
    var data = await GetSomeDataAsync(); // note no ConfigureAwait(false)
    // not shown: use "data"
}
async Task<Foo> GetSomeDataAsync() {
    using(var conn = CreateConnection()) {
        await conn.OpenAsync().ConfigureAwait(false);
        ...
        int result = await cmd.ExecuteNonQueryAsync().ConfigureAwait(false);
        ...
        return ...
    }
}

, , - TransactionScope , , , , , . : , , . , , : , .

+4

Source: https://habr.com/ru/post/1673004/


All Articles