タイマーを停止したいのですが、ティックの途中で、ティックが終了する前です。しかし、ボタンを使用してタイマーを停止すると、ダニがすべての機能を終了した後にのみ停止します。
4 つのラジオボタンと、選択したラジオボタンを変更し続けるタイマーを使用しています。停止ボタンを押すと、タイマーが停止し、どのラジオボタンが選択されているかを知る必要がありますが、ティックが終了するとタイマーが停止するため、選択されたラジオボタンが変更されます。
コードは次のとおりです。
namespace teste_bola
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Int32 x = 1000;
private void ini_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
}
private void par_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
}
private void t_Click(object sender, EventArgs e)
{
Int32 Intervalo = Convert.ToInt32(tb.Text);
x = Intervalo;
}
private void timer1_Tick(object sender, EventArgs e)
{
r3.Select();
System.Threading.Thread.Sleep(x);
r2.Select();
System.Threading.Thread.Sleep(x);
r1.Select();
System.Threading.Thread.Sleep(x);
r2.Select();
System.Threading.Thread.Sleep(x);
r3.Select();
System.Threading.Thread.Sleep(x);
r4.Select();
System.Threading.Thread.Sleep(x);
}
}
}