Good I'm doing in window form a mini system that when there are 2 buttons
1: first button called a raffle is to appear at a certain time and my 8 numbers appear label 2: regenerate button is only bleach is to say that they are visible again
but my problem is that when I first put the draw button shows correctly a certain time,
Now when he finishes and I put the second button and then I press the first button, he shows me suddenly.
This is the part of the window form view
this is my code for the first button:
private void button3_Click(object sender, EventArgs e)
{
SetInterval(1000, (obj, ev) =>
{
if (!lbln1.Visible)
{
lbln1.Show();
}
else if (!lbln2.Visible)
{
lbln2.Show();
}
else if (!lbln3.Visible)
{
lbln3.Show();
}
else if (!lbln4.Visible)
{
lbln4.Show();
}
else if (!lbln5.Visible)
{
lbln5.Show();
}
else if (!lbln6.Visible)
{
lbln6.Show();
}
else if (!lbln7.Visible)
{
lbln7.Show();
}
else if (!lbln8.Visible)
{
lbln8.Show();
}
else if (!label1.Visible)
{
label1.Show();
}
else if (!lblcliente.Visible)
{
lblcliente.Show();
}
else if (!lbloficina.Visible)
{
lbloficina.Show();
}
else if (!lblfelicitaciones.Visible)
{
lblfelicitaciones.Show();
}
else if (!lbldireccion.Visible)
{
lbldireccion.Show();
}
});
}
Second Button:
private void button1_Click(object sender, EventArgs e)
{
DialogResult res = MessageBox.Show("Desea Sortear Nuevamente?", "Aviso del sistema",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (res == DialogResult.Yes)
{lbln1.Text = "";
lbln2.Text = "";
lbln3.Text = "";
lbln4.Text = "";
lbln5.Text = "";
lbln6.Text = "";
lbln7.Text = "";
lbln8.Text = "";
lblcliente.Text = "";
lblfelicitaciones.Text = "";
lblnoesganador.Text = "";
lbloficina.Text = "";
lbldireccion.Text = "";
label1.Text = "";
MessageBox.Show("Se regenero el sorteo correctamente", "Aviso del Sistema");
button2.Enabled = false;
}
}
this is my void SetInterval
private void SetInterval(int interval, EventHandler callback)
{
//Creo el temporizador
Timer timer = new Timer();
//Le establezco el intervalo en el que va a repetir la operación
//timer.Interval = interval;
timer.Interval = interval;
//Asigno que se ejecutara al llegar el tiempo estimado
timer.Tick += (obj, ev) =>
{
//En este caso ejecuto el callback que paso como parametro
callback(obj, ev);
};
//Inicializo el temporizador
timer.Start();
}