What happens if the object referenced by the DataSource property in a ListBox
is updated by another thread? Is ListBox smart enough to check InvokeRequired
before updating the GUI based on the change? IList doesn't publish any
events, so it's not clear how the changes to the IList are being detected
under the covers.

Re: DataSource Property and Thread Safety by Andrew

Andrew
Sat Apr 23 10:52:35 CDT 2005

Even if the listbox wanted to make that check, it wouldn't matter because
the bindingmanager is not threadsafe. As documented in the ms docs, the
bindingmanagerbase class' instance methods are not thread safe. Basically,
you should not manipulate the underlying datasource from any thread but the
ui thread. The other option is to manipulate a different object that will
serve as a datasource and when you are done manipulating that, marshall a
call to the ui thread and then set the databound objects to use the new
object as its datasource.

"pearsons_11114" <pearsons11114@discussions.microsoft.com> wrote in message
news:402B358D-507C-47FA-BDFE-16D2F293C955@microsoft.com...
> What happens if the object referenced by the DataSource property in a
> ListBox
> is updated by another thread? Is ListBox smart enough to check
> InvokeRequired
> before updating the GUI based on the change? IList doesn't publish any
> events, so it's not clear how the changes to the IList are being detected
> under the covers.




Re: DataSource Property and Thread Safety by pearsons11114

pearsons11114
Sat Apr 23 11:21:02 CDT 2005

I was afraid of that. Thanks for the doc pointer as well.