NSTerminateLater and thread
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