Hi, your code looks a bit weird to me. Here are some comments: 1. AddFiles(label1.Text); is strictly not OK, you are touching a Control from a thread other than the main one. A better approach is to read label1.Text before launching the thread, then pass the string to it somehow (class member, or ThreadStart parameter). 2. the progressbar code will never execute: progressBar1.InvokeRequired and listBox1.InvokeRequired are bound to have the same value, so either the first if block's return will fire, or both if blocks will be skipped. 3. the whole threading approach is flawed: there really isn't any code running on the separate thread, all it does is cause the outermost AddFiles() to run on the main thread, so the hierarchical scan is all on the main thread (which will be very busy and uncapable of serving the GUI). Solution: split the action in two parts, the first part scanning the file system and storing strings in a collection (all on the separate thread), the second part adding the collection's content to the ListBox. 4. Lastly, this is a typical job a BackgroundWorker is good at. It would do the scanning in the DoWork handler, and the ListBox updating in the RunWorkerCompleted handler. You wouldn't need to call Invoke at all, the BGW does that for you. PS: you may want to read this my little article[^] on the matter. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.