• 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
Notifications on main thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Notifications on main thread


  • Subject: Notifications on main thread
  • From: Jonny Taylor <email@hidden>
  • Date: Tue, 18 May 2010 15:34:21 +0100

Hi all,

I have been programming on the mac for many years but have only just started trying to get the hang of cocoa. I have a particular question about NSNotification that I hope somebody will be able to help with.

My code works with a firewire video camera, and receives callbacks from the camera driver when a new video frame is received. Whenever this occurs, the UI needs to be updated to display the latest video frame. The UI update must run on the main thread - the callback thread is not a suitable place to do the update. Furthermore I would like to use NSPostWhenIdle and coalescing - if several new frames arrive between updates then we only need to draw the most recent.

I am not sure how I should be achieving this.
- I can call enqueueNotification on the default queue, but this will never run since the callback thread is not running a CFRunLoop, and is not the thread I wanted it to run on anyway.
- I could try acquiring the NSNotificationQueue for the main thread, but there does not appear to be a standard way of doing that. I have seen this suggested as a strategy elsewhere, but I think I have also read that one is not meant to post to queues other than that of the current thread (not sure why...).
- I could try using NSDistributedNotificationCenter, but that seems overkill for what I want in terms of performance and its inherent limitations.

I feel there must be a simple way of doing what I want - can anybody advise?

Thanks in advance
Jonny


_______________________________________________

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

  • Follow-Ups:
    • Re: Notifications on main thread
      • From: Jean-Daniel Dupas <email@hidden>
    • Re: Notifications on main thread
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Cancelling a loading loop in order to load something else
  • Next by Date: Re: Notifications on main thread
  • Previous by thread: Re: Cancelling a loading loop in order to load something else
  • Next by thread: Re: Notifications on main thread
  • Index(es):
    • Date
    • Thread