checking status of a background app in a Cocoa program

  • I want my main (Cocoa-based) application to track the status of a
    background application - i.e. to notice when the background
    application starts and stops. NSWorkspace won't work for background
    applications. I have a Carbon application that does the monitoring
    just fine (based on the ObserveProcessLife Carbon example). Can I
    integrate the functionality of this program into my Cocoa program?
    Basically, the Carbon app registers launch and terminate functions in
    main.c that are called at the right times. Can I just link to Carbon
    as well as Cocoa and do the same thing in my main function, or does
    the Carbon example rely in the Carbon event loop running (or on some
    other aspect of Carbon programs.) Or is there another way to do this
    monitoring without continual polling (ugh)?

    Thanks for any pointers,

    Don
    --
    Donald S. Hall, Ph.D.
    Apps & More Software Design, Inc.
    <don...>
    http://www.appsandmore.com
  • On 24.09.2007, at 07:58, Donald Hall wrote:

    > Basically, the Carbon app registers launch and terminate functions
    > in main.c that are called at the right times. Can I just link to
    > Carbon as well as Cocoa and do the same thing in my main function,
    > or does the Carbon example rely in the Carbon event loop running
    > (or on some other aspect of Carbon programs.)

    UI parts of Carbon rely on it, which doesn't make it mutually exclusive.
    I'd guess for your purpose you should be able to get away with
    CarbonCore, and that's safe to use under nearly all application types
    (also daemons et al).

    > Or is there another way to do this monitoring without continual
    > polling (ugh)?

    Mach messaging, AppleEvents, distributed objects, network sockets,
    pipes - just as some starting points.

    Regards,
    Tom_E
  • On Sun, 23 Sep 2007 23:58:53 -0600, Donald Hall <don...> said:
    > I want my main (Cocoa-based) application to track the status of a
    > background application - i.e. to notice when the background
    > application starts and stops. NSWorkspace won't work for background
    > applications. I have a Carbon application that does the monitoring
    > just fine (based on the ObserveProcessLife Carbon example). Can I
    > integrate the functionality of this program into my Cocoa program?
    > Basically, the Carbon app registers launch and terminate functions in
    > main.c that are called at the right times. Can I just link to Carbon
    > as well as Cocoa and do the same thing in my main function

    You needn't do it in your main function, but basically, although I have
    never heard of "the ObserveProcessLife Carbon example", the answer should be
    yes. The example probably uses Carbon events, which you can certainly use in
    your Cocoa app. What I do is to call InstallApplicationEventHandler in
    applicationDidFinishLaunching. This lets you designate a callback function,
    and sure enough, that callback function is called whenever the change I'm
    "listening" for occurs. m.

    --
    matt neuburg, phd = <matt...>, <http://www.tidbits.com/matt/>
    A fool + a tool + an autorelease pool = cool!
    One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
    AppleScript: the Definitive Guide - Second Edition!
    <http://www.amazon.com/gp/product/0596102119>
previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today