Android AsyncTask - avoid multiple instances running -



Android AsyncTask - avoid multiple instances running -

i have asynctask processes background http stuff. asynctask runs on schedule (alarms/service) , sometime user executes manually.

i process records sqlite , noticed double-posts on server tells me sometime scheduled task runs , @ same time user runs manually causing same record read , processed db twice. remove records after processed still this.

how should handle ? maybe organize kind of queing?

you can execute asynctask's on executor using executeonexecutor()

to create sure threads running in serial fashion please use: serial_executor.

misc: how utilize executor

if several activities accessing db why don't create sort of gateway database helper , utilize synchronized block ensure 1 thread has access @ instant

android

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -