I have a proguesBarr
defined in my program as visible=false
I want to show and activate when clicking create new game, this button is to initialize all user data in the database, with the Default data required which takes between 2 and 3 seconds. I have tried doing it in a normal timer
;
public void InsertarPartida()
{
idPartida = maxID();
String nombre = txtNuevaPartida.Text;
fb.lblNombre = nombre;
if (txtNuevaPartida.Text != "")
{
progressBar1.Visible = true;
timerBarraProgreso.Start();
using (SQLiteConnection con = new SQLiteConnection(conectionString))...
cargarDatosPorDefecto();
tutorial = true;
abrirInicioJuego();
}
else
{
mens.mensaje = "Introduce un nombre para poder dirigirnos a ti :)";
mens.ShowDialog(this);
}
}
Here is the code of timer
that I throw in the method;
private void timerBarraProgreso_Tick(object sender, EventArgs e)
{
this.progressBar1.Increment(10);
}
Another option that I have tried is to launch the progress bar timer in a secondary thread;
private void lanzarHiloProgressBar()
{
this.progressBar1.Visible = true;
this.progressBar1.ForeColor = Color.Blue;
Thread t = new Thread(timerBarraProgreso.Start);
t.Start();
}