JDivideWork demo

    await divideWorkByTaskProvider.WhenAll(new DivideWorkOption
                {
                    Action = o =>
                    {
                        var item = o as DivideTaskInfo;
                        if (item == null) return;
                        for (var i = item.BeginIndex; i < item.EndIndex; i++)
                        {                          
                            var person = personInfo[(int)i];
                            //Do something.....
                            Do(person).Wait();
                        }
                    },
                    TaskNum = personInfo.Count < 10 ? 1 : 10,
                    Count = personInfo.Count
                });

 

posted @ 2021-12-29 08:53  b̶i̶n̶g̶.̶  阅读(5)  评论(0编辑  收藏  举报