G
Guest
Hello,
I have a DataGridView, bound to a typed DataTable (without any TableAdapter
etc.).
The values of that DataTable are changed in a second thread using the
following code:
DataSetOrderManager.DbOrderManagerWlanRow row =
dtWlan.FindByHardwareID(HardwareID);
if (row != null)
row.LastVitalSign = DateTime.Now;
row.LastIP = FromIpAddress.ToString();
row.LastAccessPoint = AccessPointMac;
}
Mostly, this is working fine, but sometimes I get an DataGridView.DataError
with the VersionNotFoundException.
I think, this happans, because the row(s) are changed in a different thread!??
I don't want to "Invoke" to the main thread, because the row(s) will be
changed very often, at worst, maybe 100 times per second!
My first attempt was just catching the DataError Event and ignoring the
error, but then, sometimes I saw wrong values in the datagrid!!
So I added a InvalidateCell in the DataError Event.
Well, it seems to work, but I think, avoiding that error is better!
Now the questions are:
1. Is it OK what I do in the DataError Event, or may this produce problems?
2. The better way: How to avoid the VersionNotFoundException?
Thanks in advance,
Robert Witter
I have a DataGridView, bound to a typed DataTable (without any TableAdapter
etc.).
The values of that DataTable are changed in a second thread using the
following code:
DataSetOrderManager.DbOrderManagerWlanRow row =
dtWlan.FindByHardwareID(HardwareID);
if (row != null)
row.LastVitalSign = DateTime.Now;
row.LastIP = FromIpAddress.ToString();
row.LastAccessPoint = AccessPointMac;
}
Mostly, this is working fine, but sometimes I get an DataGridView.DataError
with the VersionNotFoundException.
I think, this happans, because the row(s) are changed in a different thread!??
I don't want to "Invoke" to the main thread, because the row(s) will be
changed very often, at worst, maybe 100 times per second!
My first attempt was just catching the DataError Event and ignoring the
error, but then, sometimes I saw wrong values in the datagrid!!
So I added a InvalidateCell in the DataError Event.
Well, it seems to work, but I think, avoiding that error is better!
Now the questions are:
1. Is it OK what I do in the DataError Event, or may this produce problems?
2. The better way: How to avoid the VersionNotFoundException?
Thanks in advance,
Robert Witter