Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# task call more web api in parallel

            foreach (var post in list)
            {
                async Task<string> func()
                {
                    var response = await client.GetAsync("posts/" + post);
                    return await response.Content.ReadAsStringAsync();
                }

                tasks.Add(func());
            }

            await Task.WhenAll(tasks);

            var postResponses = new List<string>();

            foreach (var t in tasks) {
                var postResponse = await t; //t.Result would be okay too.
                postResponses.Add(postResponse);
                Console.WriteLine(postResponse);
            }
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# short 
Csharp :: 1180 - Lowest Number and Position C# 
Csharp :: c# use meditor from service 
Csharp :: backcolor app winform C3 
Csharp :: mydata api .net 
Csharp :: c# inject dll into process 
Csharp :: unrecognized escape sequence c# connection string 
Csharp :: TextBox filling in C# 
Csharp :: unity diference protected and virtual 
Csharp :: scroll two divs simultaneously site:stackoverflow.com 
Csharp :: sqlite dapper bulkcopy 
Csharp :: c# convert timestamp to datetime 
Csharp :: DateTime2 error in EF Blazor Web Application 
Csharp :: c# encrypt folder SHA512 
Csharp :: query into complex object using dapper 
Csharp :: music file explorer c# 
Csharp :: syncfusion worksheet get last row with value 
Csharp :: Using a Views in .net and c# 
Csharp :: Devexpress MVC Gridview BinaryImage Picture 
Csharp :: unity number generator 
Csharp :: delay seconds in unity 
Csharp :: C# Move Camera Over Terrain Using Touch Input In Unity 3D - Append To Camera 
Csharp :: use Multiple forms in one Csharp panel in one Windows Form panel 
Csharp :: ascii art american flag 
Csharp :: random.choice c# 
Csharp :: how to disable button until the value is selected c# 
Csharp :: unity custom editor draw line in scene 
Csharp :: Rotate Object with keyboard 
Csharp :: wpf c# add style to object 
Csharp :: unity insert variable into string 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =