what is the situation? I use multithreaded Task to grab the data. How can I save the database after capturing the data? The database is sqlite.
1. At first, I want to store the database directly in task, but in the case of multithreading, there will be multiple threads operating a database file at the same time. I wonder if there will be conflicts. What is the maximum number of connections the database can bear?
2. Later, I want to open a separate thread to store only the database, and all the data in the Task is handed over to this database thread. But I don"t know how to make it happen.
here is the pseudo code
//
private void button1_Click(object sender, EventArgs e){
for(int i = 0; i < 10000; iPP){
var task = new Task(dataTask,i);
task.Start();
}
}
// task
private void dataTask(object obj){
int i = (int)obj;
List<string> list = new List<string>(); //
//
Thread.Sleep(1000);
list.Add("A"+i);
list.Add("B"+i);
list.Add("C"+i);
//ui
this.BeginInvoke(updateUI, i);
//list
//
//
//???
}
Thank you for your comments?