10-15-2012 02:49 PM - edited 10-15-2012 02:50 PM
My app comprises of two threads. One has the main event handler which simply listens for events on the active channel. The second does bps_channel_push_event to push user events on this channel. I store the channel id in a global, g_Channel.
This works most of the time, i.e. I can push user events from thread 2 and receive them on the first thread. However, when I click standby button (power button) and return to the app, sometimes user events stop working. Is it possible the active channel has changed after coming back from standby? Do I need to recheck the active channel id? Can you think of any reasons for this odd behaviour?
10-15-2012 03:01 PM
10-15-2012 03:28 PM
Funny you should mention run_when_backgrounded. When the user presses standby I suspend my threads explicitely (i will call this user_suspend). Is it possible before I have a chance to suspend properly, the system will suspend my threads (i will call this system_suspend)?
This would mean that when it system_resumes, it will leave where it left off which is to enter my app's user_suspended state. Seems like possible race condition.