I am faced with the following issue: I need to add all the files in a folder (chosen by the user) to a CheckedListBox (.Net 2.0). The user has the option to recurse subdirectories, which can naturally lead to a lot of files being added, which hangs the program.
To solve this I have created a separate class (potential design flaw?) that adds the files to the CheckedListBox. The method for doing so is being run in a separate thread, hence the problem: I get warned whiloe debugging that the control is being accessed by a thread other than the one it was created in. Is this a real problem? The program runs well outside debug mode and while the thread is running no other operations are being made on the CheckedListBox (except probably an occasional scroll by the user, which works fine). I have skimmed through a Microsoft example of safe cross-threading actions for Windows Forms, but it's beyond my level of comprehension for now.
Am I missing something? Is there a way to solve this while preserving responsiveness? You have probably realised by now that I am still learning, so I apologize if this is too basic. Thanks in advance.
To solve this I have created a separate class (potential design flaw?) that adds the files to the CheckedListBox. The method for doing so is being run in a separate thread, hence the problem: I get warned whiloe debugging that the control is being accessed by a thread other than the one it was created in. Is this a real problem? The program runs well outside debug mode and while the thread is running no other operations are being made on the CheckedListBox (except probably an occasional scroll by the user, which works fine). I have skimmed through a Microsoft example of safe cross-threading actions for Windows Forms, but it's beyond my level of comprehension for now.
Am I missing something? Is there a way to solve this while preserving responsiveness? You have probably realised by now that I am still learning, so I apologize if this is too basic. Thanks in advance.