Checking for conditions while rest of the application keeps on running

Hi all,

I’m trying to have my application check if a specific process is running, but while it’s doing that the rest of the application still needs to function normally.
With the script below the entire application ends up in the repeat until the value is True.

Does anyone know how to do that?


   delay 5
   set ProcessRunning to process_running("some process")
if ProcessRunning is true then
-- set content of some text field to some value
end repeat

on process_running(process_name)
	return (do shell script "ps axc") contains process_name
end process_running