Peter Duniho
7/3/2008 3:31:00 AM
On Wed, 02 Jul 2008 12:36:34 -0700, TheVillageCodingIdiot
<whosyodaddy1019@hotmail.com> wrote:
> on my form I have a function that returns a SQL connection depending
> on what is selected in a combo box. Once a button is clicked it starts
> a backgroundworker thread and Im trying to call the function on the
> form to get the SQL connection but getting error that its being
> accessed outside the original thread. How do I go about getting the
> returned SQL connection into the background worker thread?
See Control.Invoke(). Alternatively, you could handle the
RunWorkerCompleted event for the BackgroundWorker, allowing you to return
the connection instance from your DoWork handler and retrieve it from the
RunWorkerCompleted handler.
Pete