This is baffling me, maybe somebody can shine the light of education on my ignorance. This is in a C# windows app. I am accessing the contents of a listbox from a thread. When I try to access it like this
prgAll.Maximum = lbFolders.SelectedItems.Count;
I get the error. However, here is the part I don't get. If I comment out that line, the very next lineforeach (string dir in lbFolders.SelectedItems)
executes just fine.
Edit: As usual, my communication skills are lacking. Let me clarify.
I know that accessing GUI items from threads other than the ones they were created on causes problems. I know the right way to access them is via delegate.
My question was mainly this: Why can I access and iterate through the SelectedItems object just fine, but when I try to get (not set) the Count property of it, it blows up.