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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to