I agree with @Simon. Paste some code so that we understand what might be wrong. Also, why are you using a timer for?
Do not assign an event DataTableto ProgressChanged. Do it in the event RunWorkerCompleted. Here is what I think you should do:
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
try
{
e.Result = GetTableData();
}
catch (Exception ex)
{
e.Result = ex;
}
}
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Result is DataTable)
{
dataGridView1.DataSource = e.Result as DataTable;
}
else if (e.Result is Exception)
{
}
}
private DataTable GetTableData()
{
DataTable table = new DataTable();
for (int i = 0; i < NumOfRows; i++)
{
backgroundWorker1.ReportProgress(i * 100F / NumOfRows);
}
return table;
}