The proper way to do it is probably to listen for Finder death using a timeout, not polling the process list.

You can either use the NSWorkspaceDidTerminateApplicationNotification or use the low level kqueue function which provide such facility.

Le 14 janv. 09 à 16:25, Chunk 1978 a écrit :

my goal is to quit an app, check to see if it has quit, and then
relaunch the app if it has quit successfully.  i'm sending
quit/relaunch commands with applescripts (tell application "Finder" |
quit | end tell, tell application "Finder | launch | end tell), and
i'm attempting to make this code work without using any type of delay
mechanism but i'm lost.

the following code works very well on quitting and relaunching the
Finder, except if the Finder is busy (copying a file, or something),
the program will continuously try to quit the finder while the finder
prompts that it's busy - it's a continuous loop... a bad scene...

essentially i need to somehow figure out how to have this loop quit
the finder, but stop the loop if it's busy...

-=-=-=-

- (IBAction)restartFinder:(id)sender
        {
        //Quit Finder
        NSDictionary* errorDict = nil;
        NSAppleEventDescriptor *returnDescriptor = nil;
returnDescriptor = [quitFinderScriptObject executeAndReturnError:&errorDict];
        
        //Check To See If Finder Has Quit
        NSWorkspace *ws = [NSWorkspace sharedWorkspace];
        NSArray *runningAppDictionaries = [ws launchedApplications];
        NSDictionary *aDictionary;

        for (aDictionary in runningAppDictionaries)
                {
                //If Finder Hasn't Quit Then Return
                if ([[aDictionary valueForKey:@"NSApplicationBundleIdentifier"]
isEqualToString:@"com.apple.finder"])
                        {
                        [self restartFinder:nil];
                        return;
                        break;
                        }
                }
        
        //If Finder Has Quit Then Continue To Relaunch Finder
        NSDictionary* errorDict = nil;
        NSAppleEventDescriptor *returnDescriptor = nil;
returnDescriptor = [startFinderScriptObject executeAndReturnError:&errorDict];
        }

-=-=-=-
_______________________________________________

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/devlists%40shadowlab.org

This email sent to devli...@shadowlab.org


_______________________________________________

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