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()?
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()?