M
Matthias S.
Hi,
I've written a simple app which should just fetch some data from a
database and render the results into a ListView.
In order to not freeze the GUI, I'm using a BackgroundWorker. The
arguments for the RunWorkerAsync are the Query to be executed and the
Connectionstring. As a result I hoped I could return a SqlDataReader.
The problem is, if I create the SqlDataReader within the
BackgroundWorker Thread, I can't access it after the Thread has exitted.
If I would create it on the Form (thus within the Forms Thread) and pass
it as an argument to the Thread, I might end up with the risk of two
Threads accessing the same resource (a Forms Property in this case) and
that doesn't sound a nice thing to do.
How can I pass the resulting SqlDataReader from the Thread back to the form?
Any help is greatly appreceated and thanks in advance!
Matthias
I've written a simple app which should just fetch some data from a
database and render the results into a ListView.
In order to not freeze the GUI, I'm using a BackgroundWorker. The
arguments for the RunWorkerAsync are the Query to be executed and the
Connectionstring. As a result I hoped I could return a SqlDataReader.
The problem is, if I create the SqlDataReader within the
BackgroundWorker Thread, I can't access it after the Thread has exitted.
If I would create it on the Form (thus within the Forms Thread) and pass
it as an argument to the Thread, I might end up with the risk of two
Threads accessing the same resource (a Forms Property in this case) and
that doesn't sound a nice thing to do.
How can I pass the resulting SqlDataReader from the Thread back to the form?
Any help is greatly appreceated and thanks in advance!
Matthias