UI and multiple processes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

UI and multiple processes

Paul Hudson
Before I go off and try it, I'd like some advice on
threads/processes and the UI.

My news reader is beginning to actually do something now (I can
browse newsgroups, read articles etc). However, some operations
(like reading the headers of a big group) take ages. I'd like
to do these in the background and update the UI as results come
in.

DO I have to worry about synchronisation at all? Can I just set
(say) the model of a presenter from any thread? Will screen
updates work as expected?

Any advice/war stories etc gratefully received :-)

P.


Reply | Threaded
Open this post in threaded view
|

Re: UI and multiple processes

Bill Schwab
Paul,

> Before I go off and try it, I'd like some advice on
> threads/processes and the UI.
>
> My news reader is beginning to actually do something now (I can
> browse newsgroups, read articles etc). However, some operations
> (like reading the headers of a big group) take ages. I'd like
> to do these in the background and update the UI as results come
> in.

Sounds great - good luck with it.

> DO I have to worry about synchronisation at all? Can I just set
> (say) the model of a presenter from any thread? Will screen
> updates work as expected?
>
> Any advice/war stories etc gratefully received :-)

You generally **DO** need to worry about synchronization; the good news is
that it's fairly easy to do.  Have your background threads decide what they
want to add to the UI and then use something like

SessionManager current inputState queueDeferredAction:[
    somePresenter model addAll:aCollection
].

You can also use timers, but, I find that threads with the right frightening
(but descriptive) mix of control structures and synchronization objects are
ultimately easier to write, debug and maintain than anything that I've been
able to do by breaking things up over little pieces of idle time.  There is
some stuff on threads on the Wiki.

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]