main window of droplet sometimes works, sometimes doesn't

In the simple demo app below I have a main window that has a status text field and a quit button. It also has a window close button.

When I run the program, then drop a file on it all is well. The quit button in the main window functions as desired.

When I drop a file on the program icon to start it up, the main window shows up but is grayed out and clicking the quit or close button has no effect until the open handler is exited.

My question: Is it possible to make the main window function normally without exiting the open handler when the app starts up from a file dropped on it?

on idle
	(* Add any idle time processing here. *)
end idle

on open names
	log "on open"
	
	set contents of text field "status" of window "main" to "processing..."
	
	repeat 8 times
		log "delay"
		delay 1
	end repeat

	set contents of text field "status" of window "main" to "done"

	--	quit
end open

-- from quit button
on clicked theObject
	log "on clicked"
	quit
end clicked

on launched theObject
	log "on launched"
	show window "main"
end launched

Model: MacBook Pro
AppleScript: 1.10.7
Browser: Safari 523.12
Operating System: Mac OS X (10.4)

Hmmm, no takers huh?

Maybe some context will make it more interesting. I’m making a concatenate program for split files. I’d like to double click the .001 file, have a choose file dialog pop up for the target, and after selected, have a small window with a progress bar and animated picture. I do the concatenation in a background process using a shell call. The progress monitors the file until it reaches the target size, then quits itself. By the way, the animation is very cute, a cat drumming it’s claws. concat…

Anyway, I have solved the problem by moving my code out of ‘on open’ and into ‘on idle’.

-- SimpleDroplet.applescript

property _Names : {}
property _Quiting : false

on idle
	log "on idle"
	if (_Names is not {} and _Quiting is false) then
		set contents of text field "status" of window "main" to "processing..."
		-- send task to background here
		repeat 8 times -- repeat till task done in real life
			log "delay"
			-- monitor and update progress here
			delay 1
			--do shell script "sleep 1" -- this will break the progress window
		end repeat
		set contents of text field "status" of window "main" to "done"
		delay 2
		set _Quiting to true
		quit
	end if
	return 1
end idle

on open names
	log "on open: " & names
	set _Names to names
end open

on clicked theObject
	log "on clicked"
	set _Quiting to true
	quit
end clicked

on launched theObject
	log "on launched"
	show window "main"
end launched

I discovered a couple of curious things. If I use a shell call to sleep instead of the delay call, the progress window freezes up like in the intitial problem. This tells me that delay is a backdoor way to multitask. The down side is that its minumum delay time seems to be a full second.

The second thing is that executing quit does not guarantee the idle will not get called again. My testing showed that there was about a 1 in 10 chance that it would be called after the quit. Hence the need for the _Quiting property.

Model: MacBook Pro
AppleScript: 1.10.7
Browser: Safari 523.12
Operating System: Mac OS X (10.4)