paraller

Paraller 并发请求

1
2
3
4
5
6
7
8
9
var url = "http://112.124.121.109:11250/order/1230a611-e189-4296-a50d-b48910bc1850";
var client = new HttpClient();
Enumerable.Range(1, 10).AsParallel().ToList().ForEach(async (item) =>
{
var watch = Stopwatch.StartNew();
var res = await client.GetStringAsync(url);
watch.Stop();
Console.WriteLine($"{watch.ElapsedMilliseconds} : {item}");
});