CHAI SDK  Version 1.3
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Threading

Keep in mind that notification handlers and asynchronous return handlers are all called from the CHAI's thread! Therefore, application variables updated by those handlers must be protected against thread concurrency.

A convenient way to avoid deadlocks is to use CPNS::ICHAI::CHAILock and CPNS::ICHAI::CHAIUnlock to protect application-side's data from unexpected accesses by the code running in the CHAI's thread.

Locking the CHAI prevents handlers being called. So you just have to call CHAILock() before accessing shared data from the application's thread, then call CHAIUnlock() when done. It is of course useless calling these methods from within a handler.