【发布时间】:2018-09-21 04:22:49
【问题描述】:
我有一个托管在 azure 上的网络作业,它需要在一个循环中进行多个异步调用。我需要您对最佳性能所需要遵循的方法的专家意见。 getpermissions1 和 getpermissions2 在内部进行了几次安静的调用(最多 300 次)
//users count is around 40K
foreach (var user in users.ToList())
{
//Get user Profile
var profile = await getUserProfile(userid); // 1 Restful Call
//user profile get 2 sets of permissions
var permissions1 = await getPermission1(profile); //Max 300 Restful Call
//user profile get 2 sets of permissions
var permissions2 = await getPermission2(profile); //Max 300 Restfull Call
//var newProfile = profile + permissions1 + permissions2
//Then post new profile to a Rest API
var response = await client.PostAsync(new Uri(url), newProfile); //Invoke and wait for response to log the message
}
【问题讨论】:
标签: c# multithreading rest async-await task-parallel-library