如何更正每個新啓動的線程使用新計數器的代碼。當你開始一個新的線程掛起舊的,而不是繼續。線程和新計數器
感謝您的幫助。
private void button1_Click(object sender, EventArgs e)
{
thread[counter] = new Thread(goThread);
thread[counter].Start();
counter++;
}
private void goThread()
{
kolejka[counter] = new PictureBox();
kolejka[counter].Location = new Point(325, n - 150);
kolejka[counter].Image = threading.Properties.Resources.car;
kolejka[counter].Size = new Size(20, 37);
this.Invoke((MethodInvoker)delegate
{
this.Controls.Add(kolejka[counter]);
});
for (int i = 0; i < 500; i++)
{
this.Invoke((MethodInvoker)delegate
{
kolejka[counter].Location = new Point(kolejka[counter].Location.X, kolejka[counter].Location.Y - 3);
this.Refresh();
});
Thread.Sleep(50);
}
}
你好,請不要污損您的文章你已採取的幫助之後。這就像在樹下遮蔽下砍樹。請允許其他未來的用戶從知識中獲益。答覆者會付出很多努力。不要把他們的寶貴時間浪費。 –