Question forkAt: Processor userSchedulingPriority

Ned Konz ned at bike-nomad.com
Mon Oct 30 20:59:52 UTC 2000


Karl Ramberg wrote:
> 
> I made this method:
> 
> progress
>         [[foo getPercentage < 1]
>                 whileTrue: [Delay forMilliseconds: 300.
>                         progress value
>                                 contents: ((foo getPercentage min: 1.0)
>                                                 max: 0.0)]]
>                 forkAt: Processor userSchedulingPriority
> 
> Now I want to terminate it from another method before
> whileTrue: becomes false.
> 
> How do I do that ?

BlockContext>>forkAt: returns a Process, which responds to terminate.

so hang on to its return value:

	myProcess _ [ ... ] forkAt: Processor userSchedulingPriority.

and then later:

	myProcess terminate.

However, if the call to contents: will change the UI, and you're
doing this in Morphic, it would be better to do this
inside a step method. Or if you're in 2.9, you can do this:

progress
        myProcess _ [[foo getPercentage < 1]
                whileTrue: [Delay forMilliseconds: 300.
			WorldState addDeferredUIMessage: [
                        	progress value
                               		contents: ((foo getPercentage min: 1.0)
                                                 max: 0.0)]]]
                forkAt: Processor userSchedulingPriority

You'd still call terminate, of course, but this keeps you from running
into problems in Morphic.

-- 
Ned Konz
currently: Stanwood, WA
email:     ned at bike-nomad.com
homepage:  http://bike-nomad.com





More information about the Squeak-dev mailing list