I want to use more threads division read a sqlite table, how to achieve it? For example: a table has 1000 rows, I want to use 2 threads read the table, every thread only read 500 rows. How to achieve it? Could anyone help me? Thank you very much!
This is my single thread code:
string conn = @"Data Source=" + AppDomain.CurrentDomain.BaseDirectory + dbName + ";Version=3;";
SQLiteConnection sqliteConn = new SQLiteConnection(conn);
sqliteConn.Open();
string selectSql = "select fieldName1,fieldName2 from TableName";
SQLiteCommand command = new SQLiteCommand(selectSql, sqliteConn);
SQLiteDataReader reader = command.ExecuteReader();
Dictionary<string, string> dic = new Dictionary<string, string>();
while (reader.Read())
{
if (reader["fieldName1"] != null && reader["fieldName1"].ToString().Trim().Length > 0)
{
dic.Add(reader["fieldName1"].ToString(), reader["fieldName2"].ToString()); // I need to storage the two field to dictionary<string,string>
}
}
reader.close();
my issue is : the tableName rows is larger, use single thread read the table is slower, how to use multithreading read the table? Could anyone help me? Thanks!