我考虑可以这样实现
方法1
使用Database.StartTransaction 当你对某个表进行修改操作时,IB会自动对该
表加表互斥锁,你不必顾虑别人对该表进行操作。
方法2
实现人工加锁。可以大家程序先约定对数据库访问时用一个MUTEX,保证取名相同
A thread uses the CreateMutex function to create a mutex object. The creating thread can request immediate ownership of the mutex object and can also specify a name for the mutex object. Threads in other processes can open a handle to an existing mutex object by specifying its name in a call to CreateMutex.
从而实现进程间的通讯。
HANDLE hMutex;
hMutex = CreateMutex
(
NULL, // no security attributes
FALSE, // initially not owned
"MutexToProtectDatabase"); // name of mutex
if (hMutex == NULL)
{
// Check for error.
}
BOOL FunctionToWriteToDatabase(HANDLE hMutex)
{
DWORD dwWaitResult;