尝试加上 out 修饰符试试?
[C#] 纯文本查看 复制代码 private void button1_Click(object sender, EventArgs e)
{
var T1 = new Task(() => getValue("1", out d1));
var T2 = new Task(() => getValue("2", out d2));
var T3 = new Task(() => getValue("3", out d3));
T1.Start();
T2.Start();
T3.Start();
Task.WaitAll(T1, T2, T3);
MessageBox.Show("ok");
}
private void getValue(string V1, out DataTable T)
{
T = new DataTable();
T.Columns.Add("A1");
switch (V1)
{
case "1":
T.Rows.Add("1");
break;
case "2":
T.Rows.Add("2");
break;
case "3":
T.Rows.Add("3");
break;
}
}
|