Drstein99 Posted October 5, 2004 Posted October 5, 2004 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? Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Administrators PlausiblyDamp Posted October 5, 2004 Administrators Posted October 5, 2004 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 Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
AlexCode Posted October 7, 2004 Posted October 7, 2004 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 Quote Software bugs are impossible to detect by anybody except the end user.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.