Hi,
I have a VB.NET app with 2 threads (form thread and worker thread).
They both query the database from time to time.
Currently I have a single OdbcConnection instance and use it in both threads. Everything works fine.
However the documentation says OdbcConnection is not thread safe.
What do you think is best?
Thanks for your help.
I have a VB.NET app with 2 threads (form thread and worker thread).
They both query the database from time to time.
Currently I have a single OdbcConnection instance and use it in both threads. Everything works fine.
However the documentation says OdbcConnection is not thread safe.
What do you think is best?
- stay as it is: 1 object shared between threads (seems to work) (what are the risks?)
- have one connection instance per thread (requires 2 tcp connections to the database, not as scalable)
- use locks: but how? just lock the connection while using CreateCommand, or during the entire query including the while loop that gets the results?
Thanks for your help.