linq2db.EntityFrameworkCore icon indicating copy to clipboard operation
linq2db.EntityFrameworkCore copied to clipboard

Avoid dealock in low thread condition (fixes #237)

Open MichalSznajder opened this issue 3 years ago • 0 comments

In low thread condition offloading to Task.Run() results in deadlock since we block on Result. On the other side if thread is available old code also blocks on Result until QueryProvider returns. So call to Task.Run can be eliminated.

Also note that ExpressionQuery<T>.ExecuteAsyncEnumerable() in linq2db is a sync call in scenarios that do not include "preambles" (so eg. typical read only queries). Thus by eliminating call to Task.Run in this scenario there never be a deadlock.

MichalSznajder avatar Jun 08 '22 08:06 MichalSznajder