• 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: Detecting if UI thread is running, and creating a UI thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Detecting if UI thread is running, and creating a UI thread


  • Subject: Re: Detecting if UI thread is running, and creating a UI thread
  • From: glenn andreas <email@hidden>
  • Date: Fri, 2 Mar 2007 08:52:09 -0600


On Mar 2, 2007, at 5:16 AM, Justin Armstrong wrote:

The problem is that we cannot assume the caller of CreateJob() is actually a Cocoa/Carbon app with a UI thread. If the caller is a command line app then there will be no UI thread to handle the event loop and respond to the button click events. So...

How can i determine if a UI thread is running?

There is no such thing as a "UI thread" - you've made some assumptions here that are going to get you stuck.


There are actually two different things going on here.

First, all UI needs to be done on the main thread, be it Carbon or Cocoa. There is always a main thread (so in Cocoa it's always safe to do performOnMainThread: et al). If you do UI from a non-main thread, it will crash sooner or later (with "sooner" being more likely).

However, not all processes can do UI. By default, command line processes don't support UI (if you try, you'll get a window that is non-responsive), since command line processes are potentially run by things via ssh on remote machines (or in the middle of the night by cron when nobody is logged on).

Instead, in a command line process, you'll need to convert the process to one that communicates with the window server via TransformProcessType, though the better solution is to bundle it as a "real" application (i.e., in a bundle, with an Info.plist file)




Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | flame : flame fractals & strange attractors : build, mutate, evolve, animate




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: Detecting if UI thread is running, and creating a UI thread
      • From: Justin Armstrong <email@hidden>
References: 
 >Detecting if UI thread is running, and creating a UI thread (From: Justin Armstrong <email@hidden>)

  • Prev by Date: Re: Using NSTextView's delegate method textView:draggedCell:inRect:event:atIndex: selectively
  • Next by Date: Help needed with saving Core Data app data
  • Previous by thread: Detecting if UI thread is running, and creating a UI thread
  • Next by thread: Re: Detecting if UI thread is running, and creating a UI thread
  • Index(es):
    • Date
    • Thread