Re: NSTerminateLater and thread
I will try that, anyway I think the OS should grant the developer to manage the logout at his wish. For example, I return NSTerminateLater, then I launch my task in a thread and, at then end of the task I call replyToApplicationShouldTerminate:YES Easy. I understand the developer could even "forget" to call replyToApplicationShouldTerminate but there are so many other bad and worse things he can do actually, so why don't give him the freedom to make this mistake too? Mistery. Regards -- Leonardo Da: Peter Lübke Data: Sat, 4 Jun 2011 04:47:48 +0200 A: Leonardo , Kyle Sluder Cc: Cocoa Developers Oggetto: Re: NSTerminateLater and thread Besides from the fact I didn't care about the aborted logout, I was wrong anyway due to bad memory :( But you can bring up an application modal window after detaching the secondary thread in applicationShouldTerminate, giving the user options like cancelling, showing a progress indicator etc.. Repeatedly call runModalSession until the task is finished or the user cancelled. This worked fine for me in a similar situation. I guess a logout will time out anyway if the task takes too long. Cheers, Peter Am 03.06.2011 um 22:23 schrieb Leonardo: > Thank you Kyle, > however, I realize, it's incredible there is no way to execute a task before > quitting the app. I easily run a task at launch but I can't run a task > before quit. The problem is that the task could a few minutes and the app > should remain responsive to the user, in the best Mac tradition. > I will struggle myself some day more on this issue. Let's cross the fingers. > > Regards > -- Leonardo > > > >> Da: Kyle Sluder >> Data: Fri, 3 Jun 2011 11:35:41 -0700 >> A: Peter Lübke >> Cc: Leonardo , Cocoa Developers >> >> Oggetto: Re: NSTerminateLater and thread >> >> 2011/6/3 Peter Lübke : >> >>> Return NSTerminateCancel when applicationShouldTerminate calls >>> ExecuteLogOutTask to be performed in a secondary thread. >>> At the end of your ExecuteLogOutTask method, call something like >>> [myApplicationDelegate performSelectorOnMainThread:(logOutTaskDidFinish) >>> withObject:nil waitUntilDone:NO]. >>> Then, in logOutTaskDidFinish, call NSApplication's -terminate: method and >>> set a flag indicating that ExecuteLogOutTask was already executed. >>> The next time applicationShouldTerminate is called, return NSTerminateNow if >>> this flag is has been set so ExecuteLogOutTask is not called forever. >>> >> >> That's not going to resume the aborted logout. >> >> Leonardo, you will need to either finish your task in the time >> allotted by NSTerminateLater, or you will need to abort logout. >> >> --Kyle Sluder >> > > > ___ 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
Re: NSTerminateLater and thread
Besides from the fact I didn't care about the aborted logout, I was wrong anyway due to bad memory :( But you can bring up an application modal window after detaching the secondary thread in applicationShouldTerminate, giving the user options like cancelling, showing a progress indicator etc.. Repeatedly call runModalSession until the task is finished or the user cancelled. This worked fine for me in a similar situation. I guess a logout will time out anyway if the task takes too long. Cheers, Peter Am 03.06.2011 um 22:23 schrieb Leonardo: Thank you Kyle, however, I realize, it's incredible there is no way to execute a task before quitting the app. I easily run a task at launch but I can't run a task before quit. The problem is that the task could a few minutes and the app should remain responsive to the user, in the best Mac tradition. I will struggle myself some day more on this issue. Let's cross the fingers. Regards -- Leonardo Da: Kyle Sluder Data: Fri, 3 Jun 2011 11:35:41 -0700 A: Peter Lübke Cc: Leonardo , Cocoa Developers Oggetto: Re: NSTerminateLater and thread 2011/6/3 Peter Lübke : Return NSTerminateCancel when applicationShouldTerminate calls ExecuteLogOutTask to be performed in a secondary thread. At the end of your ExecuteLogOutTask method, call something like [myApplicationDelegate performSelectorOnMainThread: (logOutTaskDidFinish) withObject:nil waitUntilDone:NO]. Then, in logOutTaskDidFinish, call NSApplication's -terminate: method and set a flag indicating that ExecuteLogOutTask was already executed. The next time applicationShouldTerminate is called, return NSTerminateNow if this flag is has been set so ExecuteLogOutTask is not called forever. That's not going to resume the aborted logout. Leonardo, you will need to either finish your task in the time allotted by NSTerminateLater, or you will need to abort logout. --Kyle Sluder ___ 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
Re: NSTerminateLater and thread
Thank you Kyle, however, I realize, it's incredible there is no way to execute a task before quitting the app. I easily run a task at launch but I can't run a task before quit. The problem is that the task could a few minutes and the app should remain responsive to the user, in the best Mac tradition. I will struggle myself some day more on this issue. Let's cross the fingers. Regards -- Leonardo > Da: Kyle Sluder > Data: Fri, 3 Jun 2011 11:35:41 -0700 > A: Peter Lübke > Cc: Leonardo , Cocoa Developers > > Oggetto: Re: NSTerminateLater and thread > > 2011/6/3 Peter Lübke : >> Return NSTerminateCancel when applicationShouldTerminate calls >> ExecuteLogOutTask to be performed in a secondary thread. >> At the end of your ExecuteLogOutTask method, call something like >> [myApplicationDelegate performSelectorOnMainThread:(logOutTaskDidFinish) >> withObject:nil waitUntilDone:NO]. >> Then, in logOutTaskDidFinish, call NSApplication's -terminate: method and >> set a flag indicating that ExecuteLogOutTask was already executed. >> The next time applicationShouldTerminate is called, return NSTerminateNow if >> this flag is has been set so ExecuteLogOutTask is not called forever. > > That's not going to resume the aborted logout. > > Leonardo, you will need to either finish your task in the time > allotted by NSTerminateLater, or you will need to abort logout. > > --Kyle Sluder ___ 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
Re: NSTerminateLater and thread
2011/6/3 Peter Lübke : > Return NSTerminateCancel when applicationShouldTerminate calls > ExecuteLogOutTask to be performed in a secondary thread. > At the end of your ExecuteLogOutTask method, call something like > [myApplicationDelegate performSelectorOnMainThread:(logOutTaskDidFinish) > withObject:nil waitUntilDone:NO]. > Then, in logOutTaskDidFinish, call NSApplication's -terminate: method and > set a flag indicating that ExecuteLogOutTask was already executed. > The next time applicationShouldTerminate is called, return NSTerminateNow if > this flag is has been set so ExecuteLogOutTask is not called forever. That's not going to resume the aborted logout. Leonardo, you will need to either finish your task in the time allotted by NSTerminateLater, or you will need to abort logout. --Kyle Sluder ___ 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
Re: NSTerminateLater and thread
Return NSTerminateCancel when applicationShouldTerminate calls ExecuteLogOutTask to be performed in a secondary thread. At the end of your ExecuteLogOutTask method, call something like [myApplicationDelegate performSelectorOnMainThread: (logOutTaskDidFinish) withObject:nil waitUntilDone:NO]. Then, in logOutTaskDidFinish, call NSApplication's -terminate: method and set a flag indicating that ExecuteLogOutTask was already executed. The next time applicationShouldTerminate is called, return NSTerminateNow if this flag is has been set so ExecuteLogOutTask is not called forever. Cheers, Peter Am 03.06.2011 um 13:49 schrieb Leonardo: 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
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 (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