Linked Questions
30 questions linked to/from Using async/await for multiple tasks
23 votes
3 answers
38k views
Async and Await with For Loop [duplicate]
I have a Windows Service that runs various jobs based on a schedule. After determining which jobs to run, a list of schedule objects is sent to a method that iterates through list and runs each job. ...
7 votes
1 answer
2k views
Firing off multiple Tasks asynchronously and waiting for them to complete [duplicate]
I have a situation where I want to fire off a user-defined number of tasks asynchronously and wait for all of them to complete. Simplified, here's what I'm dealing with: [TestMethod] public async ...
-4 votes
1 answer
1k views
c# asynchronous method not work [duplicate]
Consider this code on a console application written with vs 2015: using System; using System.Threading.Tasks; public class Example { public static void Main() { Console.WriteLine("...
0 votes
1 answer
329 views
Async or parallel tasks - C# [duplicate]
I have an application where I need to do two I/O tasks: get a GPS location, retrieve some data over Bluetooth. Both tasks can vary in time to complete, and can take many seconds. To improve the speed ...
0 votes
3 answers
1k views
Await async call in for-each-loop [duplicate]
I have a method in which I'm retrieving a list of deployments. For each deployment I want to retrieve an associated release. Because all calls are made to an external API, I now have a foreach-loop in ...
0 votes
1 answer
376 views
Can this async/await code be rewritten using Task.WhenAll(...) or something else that makes more sense then awaiting each time? [duplicate]
I have the following piece of code (changed the names of my classes/objects for brevity). It essentially is hitting an external API that allows only a single operation, but my service code will expose ...
0 votes
1 answer
539 views
how to run two different asynchronous methods in different threads c# [duplicate]
I have a scenario where in My .Net Standard project,I have a api public async Task SendMessageAsync(){ await _service1.SendmessageToRestServiceAsync(); - calls a rest service await _service2....
-1 votes
1 answer
541 views
Execute two queries as tasks [duplicate]
I need help understanding how Task work in c#. I want to call ExecuteClause once for every clause in clauses. I've figured out that I should create a list of tasks and then await Task.WhenAll(...
-2 votes
1 answer
117 views
awaiting 2 methods instead of 1 [duplicate]
I am trying to start a count and then another method will stop this counting by generating a random number between 1 and 6 seconds. I can do the counting but stopper function did not start ...
0 votes
0 answers
33 views
Find out when multiple threads are finished [duplicate]
Suppose we have this scenario: In a database, there are Car1, Car2, Car3. To get these objects, we will do three queries. But, instead doing : Car car1 = await ApiHelper.GetCar1(); Car car1 = await ...
0 votes
0 answers
31 views
How to wait for all tasks in parallel are completed, and then do something later? [duplicate]
Im trying to run a list of HttpRequest tasks parallelly (not just asynchronously), and Only after all tasks are completed- output results. But when i run my code it doesnt wait but run the whole ...
318 votes
11 answers
303k views
Parallel foreach with asynchronous lambda
I would like to handle a collection in parallel, but I'm having trouble implementing it and I'm therefore hoping for some help. The trouble arises if I want to call a method marked async in C#, ...
539 votes
4 answers
205k views
WaitAll vs WhenAll
What is the difference between Task.WaitAll() and Task.WhenAll() from the Async CTP? Can you provide some sample code to illustrate the different use cases?
10 votes
3 answers
3k views
How do I prevent "maxing out" of CPU: Synchronous method calling multiple workers asynchronously & throttling using SemaphoreSlim?
I am currently optimizing an existing, very slow and timing out production application. There is no option to re-write it. In short, it is a WCF service that currently calls 4 other "worker" WCF ...
9 votes
2 answers
1k views
Async code appears to be partially blocking when calling multiple async tasks in a row (using HttpClient)
I've been trying to learn C#'s async with HttpClient and have come across an issue where I can't figure out what's happening. What I want to do: Send multiple HttpClient requests in one go and have ...