Update progress bar status in real time

Hello,
I managed to update my progress bar status in real time as my app processes files and it works fine in one part of my app.
However, in the other tabs, the progress bar doesnt start until the 20th file or so, and doesnt go all the way to the end of the bar. I did set it max value to the number of files to process though… and i dont get it !

example code:

--- my code ...
set maximum value of progress indicator "progressBar" of window "Panel1" to (count of the item_list)
	repeat with i from 1 to (count of the item_list)
		set content of progress indicator "progressBar" of window "Panel1" to i
		set contents of text field "occurrences" of window "Panel1" to "Processing item " & i & " of " & (count of the item_list) & " in this folder"
		update window "Panel1"
		set this_item to item i of the item_list
--- rest of my code ...
	end repeat

this part of my code for example, works fine but doesnt let the progress bar go to the end of the progress bar.
what could could be the cause of that ?

It looks to me like your code is correct, but that may not be your problem. Sometimes your program is busy doing something and therefore the objects in your interface don’t have time to visually update their values. This is what threading is for. Sometimes you have to do the work of your code in a different thread so that your interface objects can be updated in real time. A progress indicator has a “threaded animation” property that can help in this situation but it doesn’t always help.

So the easiest thing you can try is to use the following code on your progress indicator…
set uses threaded animation of myProgressIndicator to true

If that still doesn’t help then you have to learn how to do some of the work in your code in a different thread from the main application’s thread. I can’t help with that because I don’t know how to do that with applescript studio projects.

I believe you could look into NSTask. (I never used that with AppleScript Studio.)