var lstCsid = lstAppoint.Select(i => i.CsId).ToList();
var lstCount = lstCsid.Count;
var pushNo = lstCount % 1000 == 0 ? lstCount / 1000 : lstCount / 1000 + 1;
var lstLstCsId = new List<List<string>>();
for (var i = 0; i < pushNo; i++)
{
lstLstCsId.Add(lstCsid.Skip(++i).Take(1000).ToList());
}
////此处使用Parallel.ForEach,先将循环处理的数据完全准备好
Parallel.ForEach(lstLstCsId, async item =>
{
await PushHelper.Push("xxxx",
new PushContent
{
C = "xxxxx",
S = PushMessageSystem.FollowUp
},
item.ToArray());
});
////此处使用Parallel.For,////此处使用Parallel.ForEach,将循环处理的数据不完全准备好,处理过程中也要准备
//Parallel.For(0, pushNo, async i =>
//{
// await PushHelper.Push("今日跟进",
// new PushContent
// {
// C = "您今日有跟进任务",
// S = PushMessageSystem.FollowUp
// },
// enumerable.Skip(++i).Take(1000).ToArray());
//});
////此处使用Parallel.ForEach
//Parallel.ForEach(lstAppoint, async item =>
//{
// var tmpAppoint = item;
// if (tmpAppoint.FollowCount > 0)
// {
// var pushResult = await PushHelper.Push("今日跟进",
// new PushContent
// {
// C = $"您今日有{tmpAppoint.FollowCount}个跟进任务",
// S = PushMessageSystem.FollowUp
// },
// tmpAppoint.CsId);
// }
//});