Problem with Data Grid

Feb 23 2007 4:38 AM

Hi
I am developing a project. In which it has two button one is start and another is stop and also a label indicating stop  time and a data grid showing the previous records.

when i click start button the process starts, when the time  is over the processing stops and this entry is entered into the data grid. I user want to stop in the middle then also  an entry made in the data Grid. This code for updation in the grid is written in a separate function.  stop button and the after completing the process  there is a call to that method. The statements in that mehod are
    DataTable dtTable = new DataTable();
    dtTable.Columns.Add("ImportName");
    dtTable.Columns.Add("StartTime");
    dtTable.Columns.Add("StopTime");
    dtTable.Columns.Add("Path");
    dtTable.Columns.Add("No Of Images");
    dtGrid.DataSource = dtTable;
    
    // Here rows are added.

The problem i am facing is  When i stop the proceess in the middle by clicking the stop button then it is working fine. When the process ends with the time constraint shown in the label then the data grid method shows the following Error

Controls created on one thread cannot be parented to a control on a different thread.

The Error is causing at the line
dtGrid.Datasource = dtTable;

Any one please Help me.
Thanks in Advance.

Ramu Medida.