I have two Windows Form
, the main one has in the middle of the screen a PictureBox
which in turn contains a GIF
of an animation "loading". The idea is that when the second Form
is activated the event load
first load the method where I have the thread, then run all the remaining code (methods, etc) and at the end another method that changes the property visible
to false
.
I explain myself with the code:
private void FrmHijo_Load(object sender, EventArgs e)
{
FrmPrincipal.Instancia.mCarga();
/*---------------------Codigo-----------------------------*/
FrmPrincipal.Instancia.mDefault();
}
This is the mCarga()
method:
public void mCarga()
{
ThreadStart delegado = new ThreadStart(mostrasPTBX);
Thread hilo = new Thread(delegado);
hilo.Start();
Cursor.Hide();
}
This is the method the delegate points to:
public void mostrasPTBX()
{
FrmPrincipal.Instancia.ptbImagenCarga.Visible = true;
FrmPrincipal.Instancia.ptbImagenCarga.BringToFront();
}
And this is the mDefault
method that only hides the PictureBox
:
public void mDefault()
{
FrmPrincipal.Instancia.ptbImagenCarga.Visible = false;
FrmPrincipal.Instancia.ptbImagenCarga.BringToFront();
Cursor.Show();
}
The problem is that when opening FormHijo
and activating the event Load
does not make visible the PictureBox
simply hiding the Cursor
as indicated in the same method, try to put a MessageBox
in the mostrasPTBX()
method and if you showed them to load the FormHijo
. Another thing, try to do it wirelessly just call the method mostrasPTBX()
within the method mCarga()
but I still had the same problem. Probably the problem is foreign to the threads besides that I am relatively new programming. I hope you can help me thanks.