Progressbar / Thread / Method Issue

HI All,

i found the following on a website a while back and could not figure out why it will not work:


1 Form
1 progress bar
1 method
1 thread
1 push button


[code]Sub CopyFiles(source as folderitem, destination as folderitem)
dim size, totalsize as integer

progressbar1.value = 0
progressbar1.maximum = progressbar1.width

for i as integer = 1 to source.count
totalsize = totalsize + source.item(i).length

for j as integer = 1 to source.count
size = size + source.item(j).length
source.item(j).copyfileto (destination)
progressbar1.value = (size/totalsize) * progressbar1.maximum

End Sub[/code]


CopyFiles( specialfolder.desktop.child("FromFolder"), specialfolder.desktop.child("ToFolder") )

Push Button:

When i run it the Method fails stating that progressbar1 doesn’t exist. I have not renamed the element…… any ideas?

You can access UI elements only from the main thread, not from threads created later in the application.

its ok I’ve got it: window1.progressbar1 - if i make reference to the form it works

hmmmmm the progress bar element doesn’t seem to move…… any ideas?