frobnicate
frobnicate
CC#
Created by frobnicate on 2/2/2024 in #help
How to avoid the Service Locator anti pattern when needing to instantiate multiple of a DI instance?
Ok
50 replies
CC#
Created by frobnicate on 2/2/2024 in #help
How to avoid the Service Locator anti pattern when needing to instantiate multiple of a DI instance?
The requests are slow, that's why I want them to be in parallel
50 replies
CC#
Created by frobnicate on 2/2/2024 in #help
How to avoid the Service Locator anti pattern when needing to instantiate multiple of a DI instance?
But if I queue with a single client I have the same issue of not having multiple concurrent requests
50 replies
CC#
Created by frobnicate on 2/2/2024 in #help
How to avoid the Service Locator anti pattern when needing to instantiate multiple of a DI instance?
If I make a queue do they run in parallel?
50 replies
CC#
Created by Zyrus on 2/2/2024 in #help
✅ Help Regarding async Method Implementation.
Then you can start both tasks, and await task2 at the bottom of the loop. In that way you're waiting for it "before the next iteration". If your task1 is also async, you need to await it somewhere btw
11 replies
CC#
Created by Zyrus on 2/2/2024 in #help
✅ Help Regarding async Method Implementation.
Also I'm not sure it makes sense to wait for a task before it has started
11 replies
CC#
Created by Zyrus on 2/2/2024 in #help
✅ Help Regarding async Method Implementation.
foreach isn't async. You can do something like:
var taskList = new List<Task<MyResult>>();

foreach(...)
{
taskList.Add(Task.Run(() => PerformWhatever());
}

var result = await Task.WhenAll(taskList);
var taskList = new List<Task<MyResult>>();

foreach(...)
{
taskList.Add(Task.Run(() => PerformWhatever());
}

var result = await Task.WhenAll(taskList);
Or you can use Parallel.Foreach https://learn.microsoft.com/en-us/dotnet/standard/parallel-programming/how-to-write-a-simple-parallel-foreach-loop
11 replies
CC#
Created by Linux on 2/2/2024 in #help
TextRPG: my combat system its very buggy because if i move to a location its must be encounter
and the combat and mapping classes?
12 replies
CC#
Created by frobnicate on 2/2/2024 in #help
How to avoid the Service Locator anti pattern when needing to instantiate multiple of a DI instance?
How do I mark it as solved?
50 replies
CC#
Created by frobnicate on 2/2/2024 in #help
How to avoid the Service Locator anti pattern when needing to instantiate multiple of a DI instance?
But thanks regardless!
50 replies
CC#
Created by frobnicate on 2/2/2024 in #help
How to avoid the Service Locator anti pattern when needing to instantiate multiple of a DI instance?
Not needing to use strings and being able to put more behaviour in the service
50 replies
CC#
Created by Linux on 2/2/2024 in #help
TextRPG: my combat system its very buggy because if i move to a location its must be encounter
$paste
12 replies
CC#
Created by frobnicate on 2/2/2024 in #help
How to avoid the Service Locator anti pattern when needing to instantiate multiple of a DI instance?
Oh well
50 replies
CC#
Created by frobnicate on 2/2/2024 in #help
How to avoid the Service Locator anti pattern when needing to instantiate multiple of a DI instance?
I had hoped I could do it with typed clients :c
50 replies
CC#
Created by frobnicate on 2/2/2024 in #help
How to avoid the Service Locator anti pattern when needing to instantiate multiple of a DI instance?
So MyService has a ctor DI IHttpClientFactory?
50 replies
CC#
Created by frobnicate on 2/2/2024 in #help
How to avoid the Service Locator anti pattern when needing to instantiate multiple of a DI instance?
500
50 replies
CC#
Created by frobnicate on 2/2/2024 in #help
How to avoid the Service Locator anti pattern when needing to instantiate multiple of a DI instance?
It's a different company that makes the external API and they haven't documented it :catshrug:
50 replies
CC#
Created by frobnicate on 2/2/2024 in #help
How to avoid the Service Locator anti pattern when needing to instantiate multiple of a DI instance?
In practice, when I use the same instance of a HttpClient, to do multiple requests on the API, it will fail. If I make a HttpClient per request, it works. I'm not sure why
50 replies
CC#
Created by Linux on 2/2/2024 in #help
TextRPG: my combat system its very buggy because if i move to a location its must be encounter
can you put your code onto a paste site so I don't have to download the code to view it?
12 replies
CC#
Created by frobnicate on 2/2/2024 in #help
How to avoid the Service Locator anti pattern when needing to instantiate multiple of a DI instance?
Because I need multiple requests to run in parrallel, and the external API does not allow multiple concurrent requests from the same client
50 replies