Multiple thread access to a single tableadapter

  • Thread starter Thread starter foolmelon
  • Start date Start date
F

foolmelon

Say if I have a single myTableAdapter instance has a myUpdate()
function accessed by 2 threads, is it possible to have folloiwng
seneriao?

1. Thread 1 calls myTableAdapter.myUpdate(), it checks whether the
connection of the table adapter is open. If not, it opens the
connection and call update query.
2. Thread 2 calls myTableAdapter.myUpdate(), it checks whether the
connection of the same adapter is open. Becuase the connection is
opened by thread 1, it does not try to open the connection again.
3. Thread 1 finishes the update call, and close the connection
automically.
4. Thread 2 then calls myTableAdapter.myUpdate() function and finds
the connection is closed. It throws an exception.

If the above is possible, what is most efficient way to fix it?
Synchronize the myTableAdapter object, or create a new myTableAdapter
instance every time calling myUpdate()?
 

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

Back
Top