|
[code=csharp] private void button4_Click(object sender, EventArgs e)
{
button4.Enabled = false;
int n = dataGridView1.RowCount;
for (int i = 0; i < n; i++)
{
Thread thread = new Thread(new ThreadStart(delegate
{
Html_buy(i);
}));
thread.IsBackground = true;
thread.Start();
Thread.Sleep(200);
}
}
private void Html_buy(int i)
{
string str_userID = read_datagridview_ret_userID;
string str_type = read_datagridview_ret_type;
WebLogin weblogin = new WebLogin();
weblogin.Get_buy_1(str_userID, pictureBox1, str_type, textBox4.Text, textBox5.Text);
}
//---------从datagridview中读数据
public delegate string MyInvoke3(int i);
private string read_datagridview_ret_userID(int i)
{
string str_userID = "";
if (dataGridView1.InvokeRequired)
{
MyInvoke3 _myInvoke3 = new MyInvoke3(read_datagridview_ret_userID);
this.Invoke(_myInvoke3, new object[] { i });
str_userID = dataGridView1.Rows.Cells[0].Value.ToString();
}
else
{
str_userID = dataGridView1.Rows.Cells[0].Value.ToString();
}
return str_userID;
}[/code]
请大神看看哪里错了,我需要根据行数来开线程,一行开一条线程。
但是我写的每条线程读的都是同一条数据。
|
|