I'm developing App wp8.1. And work with SQLite. I stuck with problem when multithread update database, I try something and see a bug like this, Database is locked or Busy. I use this code:
Task.Run(delegate()
{
GetList_Story();
GetList_Category();
GetList_Story();
});
In 3 method like this:
async public void GetList_Source()
{
var postrequest = (HttpWebRequest)WebRequest.Create(ServerApilistsource);
postrequest.Method = "GET";
postrequest.CookieContainer = new CookieContainer();
HttpWebResponse postresponse = (HttpWebResponse)await postrequest.GetResponseAsync();
string response = String.Empty;
if (postresponse != null)
{
var postResponseStream = postresponse.GetResponseStream();
var postStreamReader = new StreamReader(postResponseStream);
response = await postStreamReader.ReadToEndAsync();
}
listsource = Newtonsoft.Json.JsonConvert.DeserializeObject<ListSource>(response);
//if dont have table then create table
foreach (var source in listsource.items)
{
DBHelper_Source.UpdateSource(source);
}
}
Please Help me ?
Aucun commentaire:
Enregistrer un commentaire