Reputation: 283
Say for example I open a connection async. I execute my reader async. I begin using my reader as normal:
if (await reader.NextResultAsync())
{
while (await reader.ReadAsync())
{
//work
}
}
I then on the same reader do a non async version of this:
if (reader.NextResult())
{
while (reader.Read())
{
//Work
}
}
Are there any known issues this can cause? I am reviewing some legacy code and this is obviously inconsistent; but is it going to cause any issues at run time mixing them like this?
Thanks,
Upvotes: 2
Views: 52
Reputation: 171178
This does not cause any issues.
In fact this is not always a bad idea. Async calls have more overhead than sync calls. It is reasonable to obtain a reader and result set asynchronously (since that might take a long time) and then synchronously reads rows (since each row is likely to be available quickly).
Upvotes: 1