controlling the time a Morph takes to display itself

Stéphane Rollandin lecteur at zogotounga.net
Fri Mar 19 09:36:09 UTC 2004


hello list;


I would like a Morph to support arbitrarily complex display. The idea is 
  to have (for each redraw) the display method stop after a given 
elapsed time so that the Morph does not slow down everything. Later on 
I'll be caching intermediary results so that the Morph will indeed be 
completely redrawn at some point, but at the moment I'm just trying to 
have it stop displaying, and I can't succeed.

here is what I tried:


drawOn: aCanvas

   aCanvas clipBy: self bounds
   during: [:tempCanvas |
				
	| begTime |
		
	super drawOn: tempCanvas.
	begTime _ Time millisecondClockValue.
	drawingProcess _ [self drawFieldOn: tempCanvas] fork.
				
	[drawingProcess isTerminated
		or: [(Time millisecondClockValue - begTime) > 100]]
	whileFalse: [5 milliSeconds asDelay wait].
				
	drawingProcess isTerminated
		ifFalse: [drawingProcess terminate]

	]


... where #drawFieldOn: is full of heavy computations (it takes about 
250 milliseconds to run).

I expected this code to allow #drawFieldOn: to run for about 100 
milliseconds then terminate its process.

but this does not work since regardless of the delay value within the 
whileFalse: block drawingProcess is never interrupted. only if the block 
is empty then drawingProcess is terminated by the last statement (but 
then nothing is drawn at all !)

what am I missing here ?



Stef









More information about the Squeak-dev mailing list