Home All Groups Group Topic Archive Search About

Updating BindingSource.DataSource from non UI thread

Author
19 Apr 2006 8:56 AM
peancor
Hello,

I have an UserControl with a BindingSource linked to a datagrid.

if i create the control and show it in a form and then try to set the
DataSource property from a non-UI thread i get a CrossThreadException as
expected. But if I only Create the control whithout showing it and then
set the datasource property from a non-UI thread and then show the
control from the UI thread all seems to work fine.

The question is. Is that correct or can i get some unexpected
behaviour?.

I am trying to do this because setting the datasource takes a long time
and lets the ui thread irresponsive.

Author
19 Apr 2006 11:08 AM
Kevin Spencer
You can do this, as long as you make sure that it is not shown until the
other thread has finished.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.

Show quote
"peancor" <x@no.email> wrote in message
news:Xns97AA6F47EAAABankor@216.196.109.144...
> Hello,
>
> I have an UserControl with a BindingSource linked to a datagrid.
>
> if i create the control and show it in a form and then try to set the
> DataSource property from a non-UI thread i get a CrossThreadException as
> expected. But if I only Create the control whithout showing it and then
> set the datasource property from a non-UI thread and then show the
> control from the UI thread all seems to work fine.
>
> The question is. Is that correct or can i get some unexpected
> behaviour?.
>
> I am trying to do this because setting the datasource takes a long time
> and lets the ui thread irresponsive.
Author
19 Apr 2006 1:02 PM
peancor
Thank you!

Show quote
"Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> wrote in
news:#jHPhG6YGHA.3328@TK2MSFTNGP02.phx.gbl:

> You can do this, as long as you make sure that it is not shown until
> the other thread has finished.
>

AddThis Social Bookmark Button