• 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
Re: updating NSView on separate thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: updating NSView on separate thread


  • Subject: Re: updating NSView on separate thread
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 1 Feb 2010 12:56:32 -0800


On Feb 1, 2010, at 12:11 PM, Patrick Cusack wrote:

As for NSRunLoop, let me see if I understand. I have created a new Thread with [NSThread detachNewThreadSelector:toTarget:withObject:]. The selector is a do loop that periodically calls a custom NSView's redisplay method that invokes [NSView setNeedsDisplay:YES].

So if I understand, you are going to keep your save code on the main thread, but spawn a background thread that periodically updates a view.


I should invoke this using performSelectorOnMainThread.

That won't work. Such requests get queued up on the main thread's runloop and won't be serviced until the next time the runloop runs, which will be after your save code finishes. (Unless you refactor your save code to crank the runloop periodically, in which case you can just put the view-redraw code there too and avoid the need for a background thread.)


If you want to go this way you'll need to do the view updating directly from the background thread. It sounds as though it's legal to update the view's state, but I'm not sure it's legal to flush the window from another thread, and without that, the view changes won't show up onscreen.

—Jens_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: updating NSView on separate thread (From: Kyle Sluder <email@hidden>)
 >Re: updating NSView on separate thread (From: Jens Alfke <email@hidden>)
 >Re: updating NSView on separate thread (From: Corbin Dunn <email@hidden>)
 >Re: updating NSView on separate thread (From: Patrick Cusack <email@hidden>)

  • Prev by Date: Re: Why can't I use any object as a key in a dictionary?
  • Next by Date: dynamic changing of ability to set multiple selections...
  • Previous by thread: Re: updating NSView on separate thread
  • Next by thread: Re: updating NSView on separate thread
  • Index(es):
    • Date
    • Thread