我在多个线程上调用特定函数,如下所示:
int q = 0;
for (int j = 0; j < number; j++)
{
int copy = q;
int copy1 = j;
if (!display_status[copy1].Equals("NO") && (selection == "ALL" || (selection == "ALL-LAE" && license[copy1] != "") || (selection == "ALL-NON LAE" && license[copy1] == "") || (selection == "AVIONICS -ALL" && trade[copy1] == "Avionics") || (selection == "AVIONICS-NON LAE" && trade[copy1] == "Avionics" && license[copy1] == "") || (selection == "AVIONICS-LAE" && trade[copy1] == "Avionics" && license[copy1] != "") || (selection == "AIRFRAME-ALL" && trade[copy1] == "Airframes") || (selection == "AIRFRAME-NON LAE" && trade[j] == "Airframes" && license[j] == "") || (selection == "AIRFRAME-LAE" && trade[j] == "Airframes" && license[j] != "")))
{
int numberofprojects = numberc;
string[] nameofproj = listc[0].ToArray();
string[] name = list[0].ToArray();//list of manpower names
string man_name = name[copy1];//Name of manpower
List<string>[] lista = new List<string>[5];
string[] status = listc[13].ToArray();
thread[copy] = new Thread(() => {new_value[copy]=graph1threader(man_name,numberofprojects, nameofproj, status);});
thread[copy].Start();
q++;
}
}
graphthreader1() 似乎没有返回任何值,因为 new_value 的所有元素即使在调用函数后也保持值 0。可能是什么原因?这个问题有简单的解决方案吗?