[squeak-dev] Re: Trying to import csv data, no love

Bert Freudenberg bert at freudenbergs.de
Thu Aug 5 08:14:27 UTC 2010


On 05.08.2010, at 09:30, Andreas Raab wrote:

> On 8/5/2010 12:03 AM, Casey Ransberger wrote:
>> Haha! UI hangs and CPU spikes to the top; battery starts draining fast.
>> 
>> "That tingling means it's working!"
>> 
>> Only takes a couple of minutes, really. I suppose this is a question I'd
>> have to ask eventually; is there a simple way to spin something like
>> this off as a separate (green) thread, such that Morphic still responds
>> while the job is running?
> 
> Sure. Try this:
> 
> [rows := CSVParser parse: file.
> SampledSound playSoundNamed: 'coyote'] forkAt: Processor userBackgroundPriority.
> 
> When the coyote howls, you're done :-)
> 
> Cheers,
>  - Andreas

... and since you presumably want to use that list for something, you need to get it back into Morphic. To safely talk from a background thread to your Morphic UI, use this:

[rows := CSVParser parse: file. 
WorldState addDeferredUIMessage: [myGUI updateList: rows].
] forkAt: Processor userBackgroundPriority.

- Bert -





More information about the Squeak-dev mailing list