Display data being processed in loop

megan_c99

New member
Joined
Sep 28, 2011
Messages
1
Programming Experience
5-10
Hi,

I have a procedure that loops through the directories and subdirectories on a file server and sets the permissions. Procedure is called on a button click on a form.

I need to display on the form which directory is being processed. Similar to if we use the Debug.writeline which writes to the output in Visual Studio. I tried using a ListBox but it only displays the last one and only displays the last one once processing is done. I want to be able to display each directory name as it is being processed.

Psuedo code as follows:

For each dir in L drive
setPermissions(dir)

'display in ListBox dir name
lstProgress.Items.Add(dir.Name)

Next

Any idea why this happens or how else i can achieve this?
Any help is greatly appreciated.

Thank you.
 
It happens because your operation is blocking the UI thread. You should do that work in a secondary worker thread, and post back progress results to the UI thread. For that the BackgroundWorker component is ideal.
 
Back
Top