• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Updating interface from a thread (was Re: 2 different questions)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Updating interface from a thread (was Re: 2 different questions)


  • Subject: Updating interface from a thread (was Re: 2 different questions)
  • From: Chris Hanson <email@hidden>
  • Date: Thu, 19 Sep 2002 01:27:40 -0500

Kubernan:

It's more effective to post two separate messages with descriptive titles if you have two questions to ask.

At 7:10 PM +0200 9/18/02, kubernan wrote:
I have a threaded method which send some elements to the GUI
(text for user information).
I know, it's not thread safe and i use lock mechanism.
But doing that, the application becomes very slow (the thread sends
elements all the time).
My question is if there is a good coding scheme to reduce the
performance degradation when a thread updates the GUI
very often ?

It sounds like what you're doing is acquiring a lock in your thread and then directly manipulating a view. If that's what you're doing, you're violating the Model-View-Controller design, and you're funneling everything through one critical section so you're not getting much of any advantage from multithreading.

You might want to try using some sort of thread-safe queue or the distributed notification center to post updates to your application's human interface instead. You might also want to throttle the amount of information your thread is posting somehow - not by reducing the amount of data, necessarily, but rather by letting more data accumulate and posting it less often.

The most important thing you need to do when debugging performance problems, however, is *profile*. Profile your code to determine where it's spending most of its time. Otherwise, you're just guessing, and it's often a shot in the dark as to whether any given change will make the performance better or worse.

-- Chris

PS - Macintosh applications don't have a "GUI," they have a "human interface." Just a bit of terminology trivia.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: 
 >2 different questions (From: kubernan <email@hidden>)

  • Prev by Date: drawing a string into an image
  • Next by Date: Re: UI: "Direct manipulation" is in conflict with "Forgiveness"
  • Previous by thread: Implementing file download (was Re: 2 different questions)
  • Next by thread: Re: 2 different questions
  • Index(es):
    • Date
    • Thread