Repository navigation
Parallel Calls. ResolveAsync vs Resolve #4136
Replies: 1 comment 1 reply
|
The default parallel execution strategy will run synchronous resolvers synchronously. Asynchronous resolvers are started synchronously, but awaited asynchronously. To have true parallel execution, in general, using asynchronous methods will suffice, as the underlying async call to the database or file system will yield and queue on a task completion thread until completed. However, if you have any long-running synchronous tasks, you will need to use It sounds like most of your calls are currently synchronous, and as such block the execution strategy from starting further calls (async or sync). I would suggest using async calls wherever possible. Does this answer your question sufficiently? I can explain further if needed and/or provide code samples. On a side note, you can probably use Cline or Roo Code to update your code more quickly than by hand. Just instruct it to change the resolvers to async, passing in a before and after sample, and repeat the same instructions for each file. Roo Code is a fork of Cline and has a few more features. Also, I am a little surprised that the code you posted above ran asynchronously, assuming you did not change any of the inner code: .Resolve()
.WithScope()
.WithServices<IQueryResolverAsync<TGraphModel>, IClaimRepository, RSINETContext>()
.ResolveAsync(async (context, resolve, claim, db) => {
// same as above
}I would expect that it would run synchronously, and that some type of Finally, for a very quick and dirty fix, you could perhaps do a search and replace as follows: // search
.Resolve(context =>
{
// replace
.ResolveAsync(async context =>
{
await Task.Yield();Here is the exact implementation: |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I inherited a bunch of code and so it's setup not 1:1 with how a lot of the sample code is and while the documentation is great it seems to just have small versions of code. The question I have is regarding By default queries are executed in parallel.
If I have a query like this. If I'm reading things correctly these two calls should run in parallel.
What I have noticed is that when we have something like the following it will do dropdown1 first and then dropdown2 second.
If I change the Resolver to
It will run them both at the same time.
In a lot of the examples
.Resolve()is just being used. Should we be trying to use.ResolveAsync()for these calls?What's even funnier when I ran into this, say I queried 2 async Resolvers in a row, the 3rd was just a Resolver and the 4th was back to Async is that the first three would run together (could tell by the logging), the 4th one even though it was Async would wait for the 3rd to finish. But if I put the 3 Async next to each other all 4 would run.
Since our app is really large and trying to change it all to make it looks like the current samples would take a long time, I'm just wondering if this is intended behavior, should we be striving for
ResolveAsync(), does it matter? Is something just not setup correctly.Thanks for reading this.
All reactions