i display a pic on picture box and then i want to display another pic after some seconds
but problem is that first image is not displaying only display 2nd image
1... display first picture from database such as
pbThumbImage.Image = new Bitmap(new MemoryStream(objEmployee.Picture));
2... and then get the reference of current main thread
Thread main = Thread.CurrentThread;
Thread.Sleep(5000);
3.. and then display another pic
pbThumbImage.Image = global::TimeEntrySystem.Properties.Resources.DefaultImage;
but problem is that first image is not displaying only display 2nd image
Loading
Ryan AlfordPosted Aug 11, 2008, 9:54 AM
you can get around this by using a Timer control. Put the timer control on the form, set it's interval to 5000, and set Enabled = FALSE. now in your current code, instead of doing a "Thread.Sleep(5000);"(also remove the other thread code), enable the timer. Double click on the timer to create the "Tick" event. In the Tick event, copy your code to display the second image.
your code would like something like this...
private void Form1_Load(object sender, EventArgs e)
{
pbThumbImage.Image = new Bitmap(new MemoryStream(objEmployee.Picture));
timer.Enabled = true;
}
private void timer_Tick(object sender, EventArgs e)
{
timer.Enabled = false;
pbThumbImage.Image = global::TimeEntrySystem.Properties.Resources.DefaultImage;
}