CopperLan SDK - Manufacturers Version 1.1
It is important to notice that notification handlers and asynchronous return handlers are called from the CHAI's thread! Beware that application variables updated by those handlers must be protected against thread concurrency.
In order to avoid deadlocks, a convenient way is to use CPNS::ICHAI::CHAILock and CPNS::ICHAI::CHAIUnlock to protect application side data from being accessed by code running from the CHAI's thread when it is not expected.
Locking the CHAI prevent handlers to be called. So you just have to call CHAILock() before accessing shared data from the application's thread, then call CHAIUnlock(). It is of course unnecessary to call these methods from within a handler.