0

I have a background thread called from a windows form that receives images from a camera and prints them on a picturebox (directly from the secondary thread). It should raise an exception, but everything seems to be ok. I’m using VS 2010 and the same thing happens when the application is called from the IDE or clicking on the exe file. If I change other controls or different properties of the picturebox itself the application crashes as expected. Someone else had a similar result.

I know I have to fix it, and I think there is plenty of information about how to do it, but I just would like to understand the reason of this strange behaviour. Any idea?

Community
  • 1
  • 1
Giuseppe Dini
  • 762
  • 7
  • 19
  • Can you post some code? – tweellt Mar 11 '14 at 23:31
  • It's probably just an oversight in the .NET code, I doubt there's a legitimate reason for it. – Jim W Mar 11 '14 at 23:54
  • for the code look at the link I posted. It's very similar to mine. – Giuseppe Dini Mar 12 '14 at 00:40
  • It might be that the Image property itself does some marshalling. The important thing is that the handle is not used on the wrong thread and maybe Image takes care of that already. – jmcilhinney Mar 12 '14 at 02:02
  • Maybe the Image property doesn't actually access the handle at all and that's why there's no issue. It's actually an ImageAnimator that handles the display of the Image in the PictureBox and it works on a secondary thread anyway, so it probably already marshals back to the UI thread to refresh the PictureBox. – jmcilhinney Mar 12 '14 at 02:08

0 Answers0