问题
Have one hidden column with encrypted values and i want to copy and decrypt these values to another column, for speed up this process i'm using parallel for loop, but it's working only on my desktop PC, when i tried it on my notebook i get these errors:
DataTable internal index corrupted: '5'
DataTable internal index corrupted: '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());
}
}
Is there any fix for it?
来源:https://stackoverflow.com/questions/51812491/c-sharp-datagridview-datatable-internal-index-corrupted-in-parallel-loop