Can I do the following?
DbContext context = ...
var task1 = (
from x in context.blah1 ...
...
select x.alice
).ToListAsync();
var task2 = (
from y in context.blah2 ...
...
select y.bob
).ToListAsync();
task1.Start();
task2.Start();
// Some more stuff here
var result1 = await task1;
var result2 = await task2;
And have the two requests go off in parallel? Or is this very naughty? And if it is very naughty, why is it very naughty? And will this cause runtime exceptions or other nastiness?
I've read that contexts are not threadsafe, but there is only one thread here, as async/await doesn't spawn new threads, so I can't see how that's an issue.
Also are the .Start()
calls necessary if I want the request to start running before // Some more stuff here
? Or does .ToListAsync()
kick off the execution itself?