C
cwineman
Hello,
Maybe someone here can tell if/how something is possible. I want to have a
form, with a place-holder panel. In that place-holder panel I will
temporarily place different controls as conditions change in my application.
For example, at the beginning of the program, controlA would be in the place
holder. Upon some event, I want to stick controlB in the place-holder panel,
let it display for a few seconds, then replace controlB with controlA in the
place-holder.
I've included some code below so people can see how I am try to do this, but
I don't think it will work. I think the problem has to do with updating the
UI from a non-UI thread. Unfortunately, I don't know the correct way.
Can anyone help me out here? Or send a link to examples of something
similar?
-cwineman
private void updatePlaceHolderPanel( string messageString )
{
ControlB controlB = new ControlB();
controlB.MessageString = messageString;
placeHolderPanel.Controls.Remove( controlA );
placeHolderPanel.Controls.Add( controlB );
Console.WriteLine("Before Pause");
//dramatic 4 second pause
Thread.Sleep( 4000 );
Console.WriteLine("After Pause");
placeHolderPanel.Controls.Remove( controlB );
placeHolderPanel.Controls.Add( controlA );
}
Maybe someone here can tell if/how something is possible. I want to have a
form, with a place-holder panel. In that place-holder panel I will
temporarily place different controls as conditions change in my application.
For example, at the beginning of the program, controlA would be in the place
holder. Upon some event, I want to stick controlB in the place-holder panel,
let it display for a few seconds, then replace controlB with controlA in the
place-holder.
I've included some code below so people can see how I am try to do this, but
I don't think it will work. I think the problem has to do with updating the
UI from a non-UI thread. Unfortunately, I don't know the correct way.
Can anyone help me out here? Or send a link to examples of something
similar?
-cwineman
private void updatePlaceHolderPanel( string messageString )
{
ControlB controlB = new ControlB();
controlB.MessageString = messageString;
placeHolderPanel.Controls.Remove( controlA );
placeHolderPanel.Controls.Add( controlB );
Console.WriteLine("Before Pause");
//dramatic 4 second pause
Thread.Sleep( 4000 );
Console.WriteLine("After Pause");
placeHolderPanel.Controls.Remove( controlB );
placeHolderPanel.Controls.Add( controlA );
}