943,838 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 5395
  • C# RSS
Jun 16th, 2005
0

New Thread is not allowing proper Paint Events

Expand Post »
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:
C# Syntax (Toggle Plain Text)
  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:
C# Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 46
Solved Threads: 2
Junior Poster
Iron_Cross is offline Offline
117 posts
since Jul 2003
Sep 19th, 2005
0

Re: New Thread is not allowing proper Paint Events

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!!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
amirmi is offline Offline
1 posts
since Sep 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Quick directory question
Next Thread in C# Forum Timeline: how to call these functions?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC