I have around 10 threads updating tables in a datatable, each running every millisecond.
When running more than 1 I get the error Index is outside the bounds of the array.
Heres what I have tried so far
public DataTable ThreadsTable = new DataTable();
ThreadsTable.Columns.Add("Thread", typeof(string));
ThreadsTable.Columns.Add("Last", typeof(string));
ThreadsTable.Columns.Add("TMS", typeof(int));
Form1.form.ThreadsTable.Rows.Add("GetTickers", "0", 0);
Form1.form.ThreadsTable.Rows.Add("KeepAlive", "0", 0);
Form1.form.ThreadsTable.Rows.Add("WeekDay", "0", 0);
Form1.form.ThreadsTable.Rows.Add("DailyProfit", "0", 0);
Form1.form.ThreadsTable.Rows.Add("NewOrderCheck", "0", 0);
Form1.form.ThreadsTable.Rows.Add("NewOrderLocate", "0", 0);
Form1.form.ThreadsTable.Rows.Add("NewOrderProc", "0", 0);
Form1.form.ThreadsTable.Rows.Add("CloseOrderCheck", "0", 0);
Form1.form.ThreadsTable.Rows.Add("CloseOrderProc", "0", 0);
tried these to update, both give error
Form1.form.ThreadsTable.Rows[8]["Last"] = startdt.ToString("mm:ss:FFF");
Form1.form.ThreadsTable.Rows[8]["TMS"] = mscomplete;
and
foreach (DataRow row in Form1.form.ThreadsTable.Rows)
{
if (row["Thread"].ToString() == "NewOrderCheck")
{
row["Last"] = startdt.ToString("mm:ss:FFF");
row["TMS"] = mscomplete;
}
}
Is there anyway to archive this using datatables? The reason I am doing it is I was directly updating a datagridview from all the threads which was causing other datagridviews to hang and need time to catch up. This way I can loop through the datatable each second and only update the main datagridview then.