Hi All
For my application I have some multi threaded c++ dll and a c# exe . Both of them are a sharing a Sqllite db. My c++ dll will inserting data to db and my c# exe displays it in datagrid .
I want to display data from db asynchronously so I am using named Mutex to access the data base. My c# exe has background worker . In Dowork of my backgroundworker I am using a timer to access the DB.
Now my problem is whenever I am trying to update my UI controls my exe is crashing.
This is how I am trying to update my Grid:
if (dgCompanyGrid.InvokeRequired)
{
//dgCompanyGrid.DataSource = dt;
GetFromDb(dt);
}
else
{
GetFromDb(dt);
dgCompanyGrid.DataSource = dt;
dgCompanyGrid.Refresh();
}
private delegate int GetFromDbDelegate(DataTable dt);
private int GetFromDb(DataTable dt)
{
try
{
if (this.InvokeRequired)
{
m_pxlog.WL("Invoke Required");
this.Invoke(new GetFromDbDelegate(GetFromDb), new object[] { dt });
return 1;
}
else
{
m_pxlog.WL("GetFromDb");
dgCompanyGrid.Refresh();
if (dt != null)
{
this.dgCompanyGrid.DataSource = dt;
this.dgCompanyGrid.Refresh();
}
return 1;
}
}
After the execution of the above statements my grid is getting refreshed after that it is crashing