I currently have a real problem with speed, and it seems to be thread related.
I read somewhere that the AppleScript code that is running within the context of a panel is in a seperate thread to the main thread. My experience indicates that this is true and that the panel thread is a lower priority thread and this is mostly what I want. But I have managed to code myself into a corner in one circumstance where this behaviour is getting in my way and I don’t know how to get out of it.
I am using the open panel dialog as follows
set thisPanel to open panel tell thisPanel set can choose directories to true set can choose files to true set allows multiple selection to true set name to "openpanel" end tell display panel thisPanel attached to window "main" return
The function returns immediately with the panel displayed. I then have the on panel ended handler
on panel ended thePanel with result theResult set the pathNames to (path names of open panel as list) AddItemsToTable(pathNames) end on panel ended
Now because the on panel ended function is still running in the panel thread, and the panel is still displayed, AddItemsToTable which has a lot of work to do is running in the low priority thread, and is snail like slow. So I tried adding the files to a global list, and then using the on idle handler to check the length of the list (I am using it for something else as well) before doing the work. Unfortunately the on idle handler also runs in its own low priority thread, so that doesn’t help.
I then thought of just using the standard additions choose folder or choose file commands because they would just block the main thread until they return. But unfortunately neither of them appear to allow you to select both files and folders.
Has anybody got suggestions as to how to get around this.