11-26-2002 03:04 AM
11-26-2002 11:22 AM
A CriticalSection is used to protect access to a portion of code. From MSDN documentation on Critical Sections: "When multiple threads have shared access to the same data, the threads can interfere with one another. A critical section object protects a section of code from being accessed by more than one thread. A critical section is limited, however, to only one process or DLL and cannot be shared with other processes."
I belie
ve what you are looking for is a mutex. A mutex is intended to be used to protect access to a shared resource, such as a GPIB board. Again from MSDN documentation: "A mutex object is a synchronization object whose state is set to signaled when it is not owned by any thread and non-signaled when it is owned. Its name comes from its usefulness in coordinating mutually exclusive access to a shared resource. Only one thread at a time can own a mutex object."
I think that the code you're going to write may look something like this:
HANDLE hMutex = CreateMutex(NULL, FALSE, "GPIBMutex");
WaitForSingleObject(hMutex);
ibwrt(ud, "Send a request to instrument");
char responseString[RESPONSE_SIZE];
ibrd(ud, responseString);
ReleaseMutex(hMutex);
Refer to your MSDN documentation for more information on mutexes and other synchronization objects. Please post again if you have more questions.
Craig
11-26-2002 07:27 PM