62,046
社区成员
发帖
与我相关
我的任务
分享
System.Timers.Timer bTimer = new System.Timers.Timer();
bTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEventAuto);
bTimer.Interval = 300000;
bTimer.Enabled = true;
public static void TimerTickAuto()
{
List<KeywordType> ktList = new List<KeywordType>();
List<autoAdjustPriceConfig> list = autoAdjustPriceConfigManage.getAutoAdjustPriceConfigList();
//始终使用5个线程处理集合
if (list.Count > 5)
{
int count = list.Count;
int size = (count / 20) + (count % 20 == 0 ? 0 : 1);
for (int i = 1; i <= size; i++)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(AutoAdjustPrice), getSize(i, list));
}
}
else
{
ThreadPool.QueueUserWorkItem(new WaitCallback(AutoAdjustPrice), list);
}
}
public static List<autoAdjustPriceConfig> getSize(int index, List<autoAdjustPriceConfig> aList)
{
return aList.Select(t => t).Skip((index - 1) * 20).Take(20).ToList();
}