我正在尝试找出一种方法来报告使用以下代码循环遍历字典的进度:
int progressTracker = 0;
foreach (KeyValuePair<string, Func<T>> methodPair in DicitionaryCollection)
{
progressTracker++;
progressTracker = (100 * progressTracker) / DicitionaryCollection.Count;
// do something with progress and collection contents
}
然而,这会不断返回值,在值方面有点跳跃。有什么想法吗?
请您参考如下方法:
使用不同的变量。
int currentProgress= 0;
foreach (KeyValuePair<string, Func<T>> methodPair in DicitionaryCollection)
{
currentProgress++;
int progressTracker = (100 * currentProgress) / DicitionaryCollection.Count;
// do something with progress and collection contents
}
