我有以下类型的 3 个列表:
- 文件夹名称:字符串
- FTP计数:整数
- 预期计数:整数
所有都相互关联(基于它们在列表中的索引),我想将它们作为参数传递给BackGroundWorker
它,在增加 FTPcount 和 Expectedcount 的同时读取 folderName。
我怎样才能通过它们(通过引用?),以便在每个完成执行后我能够看到增量?
List<string> folderName = new List<string>();
List<int> Expectedcount = new List<int>();
List<int> FTPcount = new List<int>();
foreach (string folder in Properties.Settings.Default.Folders)
{
BackgroundWorker bg = new BackgroundWorker();
bGs.Add(bg);
Expectedcount.Add(new int());
FTPcount.Add(new int());
folderName.Add(folder);
bg.DoWork += new DoWorkEventHandler(Process_Instiution);
bg.RunWorkerAsync(new { folderName = folder, Expected = Expectedcount[Expectedcount.Count - 1] as object, FTP = FTPcount[FTPcount.Count - 1] as object });
}
while (true)
{
bool IsBusy = false;
foreach (BackgroundWorker bg in bGs)
if (bg.IsBusy)
{
IsBusy = true;
break;
}
if (IsBusy)
Application.DoEvents();
else
break;
}
//Code to read the various List and see how many files were expected and how many were FTPed.