Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am removing and adding items from my list view in other threads.

 

Sometimes the program will try to run the enumerator to seach the list, and during that it might be adding or removing an item, which throws an error.

 

Dim myEnum As IEnumerator = internalListView.Items.GetEnumerator()

 

Do While (myEnum.MoveNext() = True)

process

loop

 

 

How do i iterate through the list and lock it just for a moment while nothing can add or remove to stop throwing errors?

www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
  • Administrators
Posted

You shouldn't be updating the UI elements from multiple threads, all UI modifications should be done from the application's main thread.

 

http://www.xtremedotnettalk.com/showthread.php?t=87035&highlight=invoke

http://www.xtremedotnettalk.com/showthread.php?t=87775&highlight=invoke

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

As this can be applyed to main thread processes too... you should allways try not to relly on UI controls, thry're mean! :mad:

 

Seriouslly, allways apply you data modifications directly to your datasource, this way you avoid, for this problem specially, threading problems, along with some other ones than only appear after the applications is deployed! :p

 

Alex :p

Software bugs are impossible to detect by anybody except the end user.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...