Control.Invoke fails at second call?

Your two ListBoxes were created on different threads. That is, in almost all cases, a really, really bad idea.

The reason why is there are 2 ListBox references in this scenario listBox1 listBox2 You only checked the InvokeRequired member for listBox1. Yet you actually end up calling . Visible on the instance originally pointed to by listBox2.

Based on the resulting behavior, it's likely that the 2 references originally pointed to 2 different instances of ListBox. To fix this, check the InvokeRequired on listBox2 since that's the one you actually end up using.

While I think you're basically right, this does not explain why listBox2 is on another thread than listBox1, since both seem to be part of the same form, which should be on a single thread. Can you create a control on a thread different from the parent's thread? This modifies the Controls property, after all... – OregonGhost Nov 30 '09 at 17:15 There is a thread that loads data to show it on listBox.

The listboxes are custom controls. I've getting a lot of error messages (Control. Invoke must be used...) if I load data directly to listBox1.

These is the reason why there are two listboxes. – VansFannel Nov 30 '09 at 17:23 @OregonGhost — yes, one can create controls on other threads and the rule is the same: all interaction with the control (excepting calling InvokeRequired) should be on the creating thread. – Paul Ruane Nov 30 '09 at 17:36 It requires some other condition to hold, for instance listBox1 was never shown.

– Henk Holterman Nov 30 '09 at 17:38.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions