Multitasking Idea

Would it be possible to create AppleScript applications which will work on an activate command (as they all do) and then use AppleScript to return results to the ASOC app with scripting commands (tell application originalapp to taketheseresults)? This would require my ASOC app to be scriptable. Would the ASOC app wait for the AS app to finish (making this useless). It would also help if the AS app was not visible in the dock.

The above would probably mean unlimited multitasking if accomplished however while waiting for a reply I tried out the perform selector way. A problem:

The usual subroutine call:

Smain(VSGgenprog + 1, (VGWpnVTgcTgOFTrun's intValue() as integer) + VSGgenprog)

The new one:

performSelectorInBackground_withObject_("Smain", {(VSGgenprog + 1), ((VGWpnVTgcTgOFTrun's intValue() as integer) + VSGgenprog)})

I did put it in with normal brackets but the compile changed it to list ones, anyway the point is I get an error:

Other failed approaches:

set abc to VSGgenprog + 1
set def to (VGWpnVTgcTgOFTrun's intValue() as integer) + VSGgenprog
performSelectorInBackground_withObject_("Smain", abc, def) 
set abc to VSGgenprog + 1
set def to (VGWpnVTgcTgOFTrun's intValue() as integer) + VSGgenprog
performSelectorInBackground_withObject_("Smain", {abc, def}) 
set abc to VSGgenprog + 1
set def to (VGWpnVTgcTgOFTrun's intValue() as integer) + VSGgenprog
performSelectorInBackground_withObject_("Smain", ({abc, def})) 

You can’t use performSelectorInBackground:withObject: for methods that take more than one argument. IAC, although AS is thread safe, there is only a single instance of AS for the application, so only one thread can be active at a time.

I tried changing this:

Smain(Va,Vb)

to this

Smain({Va,Vb})

and failed, is that not 1 parameter? The log still says {} as though I’m not passing anything if you look. ^

Proof:

performSelectorInBackground_withObject_("Smain", abc)
on Smain(VSLa) --VSLb

Exact same kind of log:

You’re calling it via Cocoa so you have to use the correct naming convention. That means an underscore for each colon, and including the colon in the method name in performSelectorInBackground_withObject_.

I am definitely and I’ve proved it’s nothing to do with multiple parameters in the comment above.

Not according to what you posted. Your handler needs to be something like:

on Smain_({Va,Vb})

That’s what the error is telling you…

Ohhh I thought you meant the perform selector.

Fixed! Thank you

Hi again, 2 problems, when I click the button which starts the background thread I can’t click tabs in the window, it’s all on spin wheel, isn’t that the point of using this? It seems to hang when trying part of this:

if (VSLn + 1) mod 100000 = 0 then
	if VSLprimenumbers is not {} then
		tell current application to write (VSLprimenumbers as string) to VSGprimefileloc starting at (get eof VSGprimefileloc) + 1
		set VSLprimenumbers to {}
		performSelectorOnMainThread_withObject_waitUntilDone_("Sreloadgenres", missing value, true) --Sreloadgenres()
	end if
end if

I’m guessing the write maybe or I’ve done the perform selector wrong.

Correction- it is definitely stuck on the performselectoronmainthread, can’t see what I did wrong, also there is no response from a log put in line 1 of Sreloadgenres.

Go back and read my first message in this thread.

Thanks for your reply again :slight_smile: the one thread at a time… Well when I start the background thread the main thread gets paused, it must be because as you said only one thread can run at a time. So doesn’t the background get paused when I do this^ Would using a 3rd thread help? Sorry, I don’t understand if I’m allowed 1, get 2 but not 3.

No. All your attempts are likely to do is lose you any control over the order they’re executed in.

Never mind, thanks loads for these many answers, I think I’ll just convert this to Obj-C later :slight_smile: