New Thread is not allowing proper Paint Events

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2003
Posts: 117
Reputation: Iron_Cross is an unknown quantity at this point 
Solved Threads: 2
Iron_Cross's Avatar
Iron_Cross Iron_Cross is offline Offline
Junior Poster

New Thread is not allowing proper Paint Events

 
0
  #1
Jun 16th, 2005
I've got a project going where I need to do some extensive searching, so I decided it would be best to put that code into a new thread. To make it a little more user friendly I decided to pop up a dialog box with a little animated image informing them that it is searching.

The problem lies in the fact that when I do this, the image will not load. I was using a PictureBox to display the image. So then I decided to try and ghettofy it and just set the dialog's backgroundimage property to the image. Which worked just fine.

But since I would like to use a the animated image, I would like to find out why it's not painting properly.

The code I'm using is:
  1. SearchDialog l_sd = new SearchDialog();
  2. l_sd.Show();
  3.  
  4. // Search is the method that does all the processing
  5. Thread l_t = new Thread(new ThreadStart(Search));
  6. l_t.Start();
  7. l_t.Join();
  8.  
  9. l_sd.Close();

So Just for kicks I deicded to NOT use a thread to do the work, but the concept was still the same (1. Show Dialog 2. Process stuff 3. Close Dialog) yet I STILL had the same problem. It will only display the picture when I use the BackGroundImage property, not a PictureBox.

The new code looked like:
  1. SearchDialog l_sd = new SearchDialog();
  2. l_sd.Show();
  3.  
  4. /*
  5.  * All the searching and crap was here
  6.  */
  7.  
  8. l_sd.Close();

Just to make matters worse, I found out that it won't even display a label. The ONLY thing it will display is the actual form, and the form background. I just don't know why it won't display labels, pictures, or anything I have heavy processing directly after the show() method.

Any help is appreciated. Thanks
elitehackers.info
Today's Penny-Arcade!
Pain is weakness leaving the body!
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1
Reputation: amirmi is an unknown quantity at this point 
Solved Threads: 0
amirmi amirmi is offline Offline
Newbie Poster

Re: New Thread is not allowing proper Paint Events

 
0
  #2
Sep 19th, 2005
Did you found the solution?

I'm Having the same problem, im doing a lengthy operation (mail merge via the code), and wanted to display an animated gif, but it didnt show until i did a this.Refresh() call - but then the gif isnt really moving...

if u managed to solve it - mail me back - please!!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC