ラジオボタンをフォームの左から右に移動するスレッドを作成しました。これは実行されますが、アプリケーションがブロックされます。フォームを移動できません。何もありません (これがスレッドを作成し、同時に複数のことを行う理由だと思いました) これが私のコードです。と尋ねた。前もって感謝します
private void moveRight( )
{
radioButton1.Left++;
}
private void moveLeft()
{
radioButton1.Left--;
}
public void run()
{
while (true)
{
while (radioButton1.Left != this.ClientSize.Width - 10)
{
if (InvokeRequired)
{
Invoke(new MethodInvoker(moveRight));
}
else
{
moveRight();
}
}
while (radioButton1.Left != 10)
{
if (InvokeRequired)
{
Invoke(new MethodInvoker(moveLeft));
}
else
{
moveLeft();
}
}
}
}
private void button1_Click(object sender, EventArgs e)
{
t = new Thread(new ThreadStart(run));
t.Start();
}