Re: Terminating from Separate Thread
Re: Terminating from Separate Thread
- Subject: Re: Terminating from Separate Thread
- From: email@hidden (Kris Rambish)
- Date: Wed, 12 Jul 2006 03:19:07 +0000
Eric,
I agree more with James. I would have the UI thread register for an notification, and have the separate thread post the notification before it terminates. When the message is processed by the UI thread it can clean up and shut down gracefully.
Another possibility would be to create a member variable flag within the separate thead that get sets when the error is encountered. However your will have to add an NSTimer to your UI thread to check the state of this flag, which is trivial. This may be similar to what Tommy suggested but I would not have the non-UI thread (the child thread) terminating the application.
Kris
-------------- Original message ----------------------
From: Tommy Nordgren <email@hidden>
>
> 12 jul 2006 kl. 01.49 skrev Eric Blanpied:
>
> > My app has a child object that handles a periodic process on a
> > separate thread. From time to time that process encounters an error
> > which requires notifying the user and quitting the app. So far I've
> > done this with an NSAlert from that thread, and then [NSApp
> > terminate: self], which seems effective.
> >
> > The trouble is that there are some things that would be good to
> > tidy up in the main thread before even showing that alert. How can
> > I have this child object, on a separate thread, tell the main app
> > to do some stuff, show the dialog (with error data from the child
> > object), & quit?
> >
> > Thanks,
> >
> > -e
> >
> >
> > _______________________________________________
> > Do not post admin requests to the list. They will be ignored.
> > Cocoa-dev mailing list (email@hidden)
> > Help/Unsubscribe/Update your Subscription:
> > 40chello.se
> >
> > This email sent to email@hidden
> Set a flag in the NSApplication delegate, to signal abnormal
> termination,
> and implement the cleanup in the applicationWillTerminate:
> delegate method.
> -------------------------------------
> This sig is dedicated to the advancement of Nuclear Power
> Tommy Nordgren
> email@hidden
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden