Jim Rand
5/21/2007 5:51:00 PM
I have a dataset that contains all data for lookup tables. It is refreshed
each 10 minutes in background picking up new and modifed rows using the
CAST(TS AS INT) > @MaxTS in the WHERE clause.
DataSet dsNewData= dsLookupTbls.Clone();
.... Fill dsNewData in background
private bool UpdateDataSet()
{
bool ok = false;
if (_GUISync.InvokeRequired)
{
ok = (bool) _GUISync.Invoke(new UpdateDataSetDelegate(UpdateDataSet),
null);
}
else
{
try
{
this.AcceptChanges();
this.Merge(_dsNewData, false);
this.AcceptChanges();
NoteMaxTimestamps();
ok = true;
}
catch (System.Exception ex)
{
_log.Warn("UpdateDataSet merge failed", ex);
ok = false;
}
return ok;
}
return ok;
}
"rfw68" <rfw68@nospam.nospam> wrote in message
news:D6EC306B-CA99-41E9-878C-229C41BCC96F@microsoft.com...
> Ah, yes!
> As I painfully figured out, ANY changes to bound DataSet elements must be
> done in the GUI thread! In this case, there are no bounds to GUI elements,
> but in an other program, I'm doing exactly this - now with invoking the
> GUI
> thread for every change.
>
> Maybe, you know a trick or someting to make a DataGridView thread safe?
> If it would be possible to syncronize the parts, where the DataGridView
> accesses the DataTable with my own thread(s)...
>
> But I'm afraid, that it is not possible to overwrite this parts of the
> DataGridView to implement at least a DataGridView which is thread save if
> it's only reading from (not writing to) the DataTable.
>
> However, thanks for your help,
> Robert Witter
>