Error with performSelectorOnMainThread

Trying to run the sample script in the note on threading in the Late Night Software page on ASObjC in SD6, I get the error “NSWindow drag regions should only be invalidated on the Main Thread!” with the script line “set theAlert to current application’s NSAlert’s alloc()'s init()” highlighted. I notice the makeAlert handler that contains that line is not called using performSelectorOnMainThread, and it’s not clear to me how to use performSelectorOnMainThread to call a handler that takes parameters. Also, I’m running SD7; has something changed since SD6, or in Catalina?

Catalina is much more restrictive in terms of what can be run on the main thread. You can use performSelectorOnMainThread:withObject:waitUntilDone: like this:

my performSelectorOnMainThread:"nameOfHander:" withObject:someValue waitUntilDone:true
[...]
on nameOfHandler:someObject
[...]

Results have to be passed back using properties or globals.

If you look at the code in my Dialog Toolkit Plus script library, you should get a good idea of how to use it.

https://www.macosxautomation.com/applescript/apps/Script_Libs.html