有一个带有加密值的隐藏列,我想将这些值复制并解密到另一列,为加快此过程,我使用了并行for循环,但是当我尝试使用它时,它仅在我的台式机上工作我的笔记本出现以下错误:
DataTable内部索引已损坏:“ 5”
DataTable内部索引已损坏:“ 13”
public void LoadKeyStarter()
{
DataTable dt;
DataSet DS = new DataSet();
mySqlDataAdapter.Fill(DS);
dt = DS.Tables[0];
dt.Columns.Add("Decrypted", typeof(System.String));
keystoregridview.DataSource = dt;
LoadKeyColumn = new Thread(LoadKeyColumnValues);
LoadKeyColumn.Start();
}
public void LoadKeyColumnValues()
{
try
{
#NOT WORKING ON NB
Parallel.For(0, keystoregridview.Rows.Count, i =>
{
keystoregridview.Rows[i].Cells["Decrypted"].Value = Decrypt(keystoregridview.Rows[i].Cells["Encrypted"].Value.ToString());
});
/* WORKING BOTH
for (int i = 0; i < keystoregridview.Rows.Count; i++)
{
keystoregridview.Rows[i].Cells["Decrypted"].Value = Decrypt(keystoregridview.Rows[i].Cells["Encrypted"].Value.ToString());
}*/
}
catch (Exception _ex)
{
MessageBox.Show(_ex.ToString());
}
}
有什么解决办法吗?