Roger,

On 02 May 2012, at 21:01, Roger Gilliar wrote:

> The following code is blocking the while UI until the whole file is read. Why 
> ?

There is only one UI thread. You make it do something that takes a long time, 
thus the whole UI is waiting.

> Is there a better way to process large text files ?
> 
> Regards
>  Roger
> 
> |stream inRec|
> 
> stream := FileStream readOnlyFileNamed: '/Users/roger/Desktop/d001.txt' .
> 
> [stream atEnd] whileFalse: [
>       inRec := stream upTo: Character cr.  
>       Transcript show: '@'.   
> ].
> 
> stream close.

Yes, try:

[ |stream inRec|

  stream := FileStream readOnlyFileNamed: '/Users/roger/Desktop/d001.txt' .

  [stream atEnd] whileFalse: [
        inRec := stream upTo: Character cr.  
        Transcript show: '@'.   
  ].

  stream close ] fork.

Sven

Reply via email to