clicked the object and idle

I am making an applescript application with studio.

I have a problem when i push a button “Start” to begin a job, i can t do anything until my job is finished.
I’d like to rename my button with “Stop” and be able to click on it to stop the job.

I ve read that i should use “on idle” to let me do that, but i can t manage it.

Thanks for your help

Hi,

this depends on the job.
For example, if you run a shell script, AppleScript waits until the shell line has been finished.
To avoid this, you must save the shell script line as an external AppleScript application,
which will be called from the main script.

To toggle a button with Start and Stop you can use something like this

on clicked theObject
	if title of theObject is "Start" then
		set isRunning to true
		set title of theObject to "Stop"
		startJob()
	else if title of theObject is "Stop" then
		set title of theObject to "Start"
		set isRunning to false
		stopJob()
	end if
end clicked