这是我的单线程代码:
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();
我的问题是:tableName行较大,使用单线程读取表较慢,如何使用多线程读表?谁能帮助我?谢谢!