Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Synchronize tasks to share access to a sqlite db

$
0
0

I have an activity which launches an AsyncTask in which I write the records in a table. In the procedure of the main Activity onResume read this data and show them in a ListView. If I rotate the device intercept the event and during OnDestroy cancel the execution of the AsyncTask using Cancel (false), so during the RunInBackground control the value of the property IsCancelled and if this is true I close the AsyncTask. Everything works fine except that sometimes I get an error of type Android.Database.Sqlite.SQLiteException because the DB is still in use by the AsyncTask because it must complete the course before finishing. How do I synchronize the main Activity, created after the device has been rotated, and the AsyncTask in order to wait for it to stop before reading the DB? Thank you.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>