Hi
I'm still analyzing to fix this issue.
Here is my code snippet:
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
using (DataSet ds = (DataSet)e.Argument)
{
sfDataGrid.DataSource = ds.Tables[0];
ds.Tables[0].Dispose();
ds.Dispose();
}
}
private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
{
MessageBox.Show(e.Error.Message, "Error");
return;
}
}
As you can see I am using backgroundWorker.
I checked e.Error.
Sometimes it works normally, and sometimes an error occurs like this.
But the code is the same.
My feeling is that this problem occurred when I used a large DataSet.
Using a small DataSet reduces this problem.
I need your help.
Regards,
Ki Hun.
|
backgroundWorker1.DoWork += backgroundWorker1_DoWork;
backgroundWorker1.RunWorkerCompleted += BackgroundWorker1_RunWorkerCompleted;
private void BackgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//set the result value to SfDataGrid.DataSource
sfDataGrid1.DataSource = e.Result;
if (e.Error != null)
{
MessageBox.Show(e.Error.Message, "Error");
return;
}
}
private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
using (DataSet ds = (DataSet)e.Argument)
{
//set the datasoure to result
e.Result = ds.Tables[0];
ds.Tables[0].Dispose();
ds.Dispose();
}
} |
Thank you.
I solved the problem in two ways.
1. Don't use BackgroundWorker.
2. Using your code snippet.
Both methods were successful.
Thank you very much for your help.
Regards,
Ki Hun