I'm porting a fairly complex Windows Mobile application to Android and I've got a question about how to port some of the background thread functionality.
The application uses a separate thread to synchronize data in the background; the thread stays alive for as long as the application is running and also polls the server for new data. In the Windows Mobile world the application never suspends; we perform an idle reset to keep the application running (as well as the background data sync) until the user explicitly logs out. This allows data from the server to arrive on the device and alert the user. I'm not sure if this is possible (or desirable) in the Android world. For the Android version this is what I have done so far: 1) created an Application level class, called Program :), that inherits Android.App.Application 2) created a static class called DataSync that is a child class of Program When the Android application class runs the Program.DataSync class handles all the background interaction with out web services. Since it lives in the Application context it also means it's fairly easy to interact with the DataSync from various activities. So from a preliminary perspective this approach seems to work well enough. The performance is good and it's similar enough to our Windows Mobile code base to make maintenance changes fairly easy. Now for the questions: Is our approach to the background thread sound in MonoDroid? I really don't want to implement an Android Service if possible; I'd rather stay with the same design we are familiar with. However if there are going to be any show stoppers with the way we have implemented it I'd rather know now? What do we do when the Android application suspends? Is there an Application level suspend event that we should hook in to - in order to suspend the DataSync class? What housekeeping do we have to do when the application loses foreground focus? If so how long does Android allow time wise for us to wrap up any current syncronizations? Is there a time limit that is deemed un/acceptable? If you've read this whole post and have some advice - thanks in advance! -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/Background-thread-best-practice-tp5085420p5085420.html Sent from the Mono for Android mailing list archive at Nabble.com. _______________________________________________ Monodroid mailing list [email protected] UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
