Blocking in onDestroy() waiting for the background thread to complete basically defeats the purpose of doing work in a background thread.
On Tue, May 26, 2009 at 7:09 AM, Gautam <gautam_raychaudh...@hotmail.com>wrote: > > Hi, > > I'm implementing a service that contains a thread to handle all > time consuming operation. My core service logic is in a different > thread than the ui or main thread. According to the Android document, > when the OS plans to free some system resource, it will call onDestroy > () on the service and only when onDestroy() returns it will kill the > process hosting the service, thus giving opportunity to the service to > cleanup. > > Now, when onDestroy() is called, I want to send a message to my > service thread to do the necessary cleanup. Only when the service > thread acknowledges that the cleanup or shutdown is complete, onDestroy > () should return. > I could find a way to send asynchronous messages to threads and the > corresponding processing of the messages, but not able to figure out > how I need to implement onDestroy(), such that it would send a message > to the service thread and should wait for a result, before returning. > > Appreciate if someone can comment on my understanding of onDestroy > () and provide some solution to the above problem. > > Thanks and Regards, > Gautam. > > > > > -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---