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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to