Find Objects Bound To DataTable?

F

Fred W.

I wondering if there is a way to determine which objects are bound to my
DataTable. I update my DataTable from a thread. My DataTable is bound to a
DataGrid in my main UI. Apparently I will need to perform my table update on
the UI Thread or the DataGrid has issues.

Ideally I would like the DataTable to tell me who is bound to it and then
check if that object implements ISynchronizeInvoke and use that to determine
that I need to actually perform the updates on that objects thread.
Otherwise, I will need to explicitely feed a reference of the GUI control to
my thread updating the DataTable. Any thoughts are appreciated. Thanks

-Fred
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,



Fred W. said:
I wondering if there is a way to determine which objects are bound to my
DataTable.

No, this is not possible.

I update my DataTable from a thread. My DataTable is bound to a
DataGrid in my main UI. Apparently I will need to perform my table update
on the UI Thread or the DataGrid has issues.

You could do the update in the thread, and use Control.Invoke to let the
datagrid knows the datatable was changed.
I will need to explicitely feed a reference of the GUI control to my
thread updating the DataTable. Any thoughts are appreciated. Thanks

I'm afraid that is what you will end doing.
 
N

Nicholas Paldino [.NET/C# MVP]

Instead of passing a reference to the thread, why not just pass an
implementation of ISynchronizeInvoke? Either that, or have a thread-static
member somewhere that the routine can check in the thread to determine if
actions need to be invoked on another thread.

You don't necessarily have to send an instance of a control in.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top