Why Locking On a Public Object is a Bad Idea

后端 未结 5 1693
时光取名叫无心
时光取名叫无心 2020-12-10 12:36

Ok, I\'ve used locks quite a bit, but I\'ve never had this scenario before. I have two different classes that contain code used to modify the same MSAccess database:

<
5条回答
  •  庸人自扰
    2020-12-10 13:05

    Use a Mutex.
    You can create mutex in main class and call Wait method at the beginning of each class (method); then set mutex so when the other method is called it gonna wait for first class to finish.
    Ah, remember to release mutex exiting from those methods...

提交回复
热议问题