Thread Results

M

Mythran

I have a thread which executes database manipulation code. I need to display the
resulting dataset into a datagrid which is located on my main form (created by
the main thread, not the child thread that created the dataset). When I try to
bind the results to the datagrid, I get the following exception:

An unhandled exception of type 'System.ArgumentException' occurred in
system.windows.forms.dll

Additional information: Controls created on one thread cannot be parented to a
control on a different thread.

Can anyone help me get the resulting data from the child thread to the main
thread so I can successfully display the results???

Thanks much :)

Mythran
 
H

Herfried K. Wagner [MVP]

* "Mythran said:
I have a thread which executes database manipulation code. I need to display the
resulting dataset into a datagrid which is located on my main form (created by
the main thread, not the child thread that created the dataset). When I try to
bind the results to the datagrid, I get the following exception:

An unhandled exception of type 'System.ArgumentException' occurred in
system.windows.forms.dll

Additional information: Controls created on one thread cannot be parented to a
control on a different thread.

Can anyone help me get the resulting data from the child thread to the main
thread so I can successfully display the results???

Have a look at 'Control.Invoke', 'Control.BeginInvoke', and 'Control.EndInvoke'.
 

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

Similar Threads


Top