Getting synchronous behavior from ToListAsync

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
jeffeynon
Posts: 3
Joined: Thu 30 Jul 2015 14:55

Getting synchronous behavior from ToListAsync

Post by jeffeynon » Thu 30 Jul 2015 15:06

Hi,

I have code in my application that uses DevArt dotConnect (version 8.4.457) to connect to an oracle 12c database. I have code that looks like this:

using (var context = new MyContext(myConnectionString)
{
var data = (some lync query).ToListAsync();
var data2 = (some lync query).ToListAsync();

etc etc....

await Task.WhenAll(new Task[] {data, data2....});
}

I have 6 somewhat long running queries (~2 seconds each) that I'm trying to execute in parallel. However this does not appear to be happening. When I run in the debugger and step through the ToListAsync, there is a noticeable pause after each ToListAsync() line like the query is actually running (I can't confirm because I don't have access to trace on the DB and these queries apparently don't show up in intellisense like others do). I would expect the first query to take a second or so to build the EF model, but the other ToListAsync() calls should return immediately. Plus, if I put a breakpoint at the await line, the tasks are ALWAYS completed. Further, according to documentation I read while researching this, the above code shouldn't even work when there are multiple async calls within a dbcontext scope because dbconext isn't threadsafe, so that further suggests that there really isn't anything async happening here.

Please confirm that ToListAsync (and other async methods) truely execute asynchronously, and if so, please advise on what is wrong here.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Getting synchronous behavior from ToListAsync

Post by MariiaI » Fri 31 Jul 2015 07:43

jeffeynon wrote:Please confirm that ToListAsync (and other async methods) truely execute asynchronously, and if so, please advise on what is wrong here.
Currently, standard async methods for .NET 4.5 are not supported in dotConnect for Oracle. Due to this fact, the default implementation is used, i.e. such methods are performed synchronously. This functionality is on our roadmap; however, we can't tell any timeframe at the moment. We will inform you when any results are available.

Also, you can vote for "Add compatibility to run ASYNC Queries" suggestion here:
http://devart.uservoice.com/forums/8026 ... nc-queries

Post Reply