• 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
NSTerminateLater and thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTerminateLater and thread


  • Subject: NSTerminateLater and thread
  • From: Leonardo <email@hidden>
  • Date: Fri, 03 Jun 2011 13:49:44 +0200
  • Thread-topic: NSTerminateLater and thread

I would like my application executes a given task before the log-out.
I almost succeeded but since this task could take a few minutes and since I
have to launch it on a separated thread (so the user could stop it), I am
getting some trouble.

In the applicationShouldTerminate method, I know that the Quit has been
invoked by the log-out thanks to the NSWorkspaceWillPowerOffNotification
So from within applicationShouldTerminate I invoke:
    [self ExecuteLogOutTask];
    return NSTerminateLater;
In this case the task gets executed properly but the user cannot cancel it.
The application looks unresponsive to the user.

So I tried:
    [NSApplication detachDrawingThread:@selector(ExecuteLogOutTask)
        toTarget:self withObject:nil];
    return NSTerminateLater;
But I get a dialog saying:
    You haven't been logged out because the application MyAppLogOut failed
    to quit. Try logging out again....
And the ExecuteLogOutTask has not been called at all.

If I return NSTerminateCancel I cancel the whole log-out, which is not what
the user expects.

So how to manage this case?


Regards
-- Leonardo


_______________________________________________

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: NSTerminateLater and thread
      • From: Peter Lübke <email@hidden>
  • Prev by Date: Re: Programmatically displaying UISplitViewController popover?
  • Next by Date: Re: Programmatically displaying UISplitViewController popover?
  • Previous by thread: Re: Handling NSRunLoop with AUGraph
  • Next by thread: Re: NSTerminateLater and thread
  • Index(es):
    • Date
    • Thread