I'm trying to make a loading for a section start form. I have put an animated gif to make the loading effect.
What happens is that when I use the property loading.Visible = true
it is not visible until the event click
ends.
Here is the code.
private void btnIniciarSesion_Click(object sender, EventArgs e)
{
loading.Visible = true;
if (ConectarBaseDatos())
{
OpenFormulario();
this.Close();
}
else MessageBox.Show("Usuario o contraseña, incorrectos");
loading.Visible = false;
}
The Database takes 3 to 6 seconds to respond in the function ConectarVaseDatos()
but the gif is not visible until the event ends.
Could someone tell me how could I do this?