Program crashing while addring rows to the table
I have a grid that uses DataView as its source
I implement the following code
Initialize()
{
DataTable table = DataTable("Table");
DataView view = new DataView(table);
DataGridTableSytle ts= new DataGridTableStyle();
ts.MappingName = table.TableName;
DataGridTextBoxColumn tCol = new DataGridTextBoxColumn();
tCol.HeaderText = "Column 1";
tCol.MappingName ="col1";
tCol.Width = 200;
tCol.ReadOnly = true;
ts.GridColumnStyles.Add(tCol);
tCol = new DataGridTextBoxColumn();
tCol.HeaderText = "Column 2";
tCol.MappingName ="col2";
tCol.Width = 200;
tCol.ReadOnly = true;
ts.GridColumnStyles.Add(tCol);
DataColumn dCol1,dCol2;
dCol1 = new DataColumn("col1",System.Type.GetType("System.String"));
dCol1.Caption = "Column 1";
table.Columns.Add(dCol1);
dCol2 = new DataColumn("Col2",System.Type.GetType("System.String"));
dCol2.Caption = "Column 2";
table.Columns.Add(dCol2);
ts.MappingName = dTable.TableName;
view = new DataView(table);
view.Table.TableName = dTable.TableName;
view.AllowEdit = false;
view.AllowDelete = false;
view.ApplyDefaultSort = false;
view.AllowNew = true;
dataGrid1.TableStyles.Add(ts);
dataGrid1.DataSource = view;
}
Thread aThread;
ButtonEvent(object sender, System.EventArgs e)
{
aThread = new Thread(new ThreadStart(UpdateGrid));
aThread.Start();
}
public void UpdateGrid()
{ int i=0;
try
{
while(true)
{
i++;
WriteData(i);
Thread.Sleep(2000);
}
}
catch(Exception Err)
{
MessageBox.Show(Err.Message);
}
public void WriteData(i)
{
view.Table.Rows.Add(new string[] {i.ToString(),i.ToString()})
}
The program seem to work fine and keep adding rows with i on the development machine... However if I run the same program on another machine the program crashes giving the following message
Application has generated an exception that could not be handled
Process id=0xc40 Thread id = 0x93C.
I was able to narrow it down to the point that I know the program crashes while adding row, Also if I was doing the same without thread it works fine. Any ideas what could be causing it to crash.
Thanks,

Answers
Know the answer? Post it. Somebody with the same question will find it here.