• 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: NSRunningApplication isTerminated bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSRunningApplication isTerminated bug


  • Subject: Re: NSRunningApplication isTerminated bug
  • From: Michael Babin <email@hidden>
  • Date: Thu, 07 Jun 2012 06:56:34 -0500

On Jun 7, 2012, at 4:51 AM, Patrick Robertson wrote:

> I seem to be having a problem with terminating apps and observing the
> 'terminated' property of NSRunningApplications. If you run my sample code
> (attached, and below), you will notice that even though Safari has quit
> (its icon has disappeared from the dock) the 'isTerminated' property
> returns NO indefinitely, causing my simple app to hang.
>
> Am I missing something blindly obvious in my code, or is this a bug with
> the NSRunningApplication?
> I have tried this with different apps, not just Safari and I get the same
> result. In my own app, I'm using the
> runningApplicationsWithProcessIdentifier: method, but it doesn't make a
> difference.

https://developer.apple.com/library/mac/#documentation/AppKit/Reference/NSRunningApplication_Class/Reference/Reference.html

"Properties that vary over time are inherently race-prone. For example, a hidden app may unhide itself at any time. To ameliorate this, properties persist until the next turn of the main run loop in a common mode. For example, if you repeatedly poll an unhidden app for its hidden property without allowing the run loop to run, it will continue to return NO, even if the app hides, until the next turn of the run loop."

In your sample code, you're polling the property without allowing the main run loop to run. Given that your sample code is a Foundation tool, you don't automatically have a runloop created for you. If this is true of your actual code as well, you'll need to create a runloop and allow it to run (explicitly in your polling loop or rewriting your code to not synchronously block the thread).



_______________________________________________

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

  • Prev by Date: Desktop geometry problem
  • Next by Date: Re: NSTextView
  • Previous by thread: Re: Desktop geometry problem
  • Next by thread: Is there a way to detect if user adds Printer?
  • Index(es):
    • Date
    • Thread