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 ?
Karl
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 wrote:
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.
You are right:-) Inside a step method everything works fine. I thought I should be clever and do something smart, no need for that. Thanks. Karl
At 21:54 30.10.2000 +0100, Karl Ramberg wrote:
Delay forMilliseconds: 300.
Side note: Keep in mind that that's a rather short delay. I guess that in your real code, there's a "(...) wait" around it.
(You may think I'm picking nits, but it's one of my favourite traps. I just keep falling in again and again. I think it has to do with the catchy name, I seem to take the noun for a verb.)
HTH, Helge
Helge Horch wrote:
At 21:54 30.10.2000 +0100, Karl Ramberg wrote:
Delay forMilliseconds: 300.
Side note: Keep in mind that that's a rather short delay. I guess that in your real code, there's a "(...) wait" around it.
You mean that's not a reliable way to make a 10 usec delay?
Sad...
squeak-dev@lists.squeakfoundation.org