Problem with Semaphore code?

 
If an expert is in the middle of processing and has locked the semaphore, and the user closes the chart window or changes the time frame or does anything else that causes the expert to deinit, won't the semaphore remain locked? That would prevent any expert from processing. You can't exactly reset the semaphore in the deinit() function because the expert that's closed may not have locked the semaphore.

Perhaps setting the semaphore to Curtime() instead of 1 to lock it would work? Then you could time out the semaphore if it remains locked for too long.

Any other ideas?

Loren
 
use IsStopped function that tell You about expert close by user
 
I don't really understand the description of IsStopped(). Could you provide a code example with the semaphore? I have IsStopped() around the GlobalVariableSetOnCondtion() call, but it didn't stop the experts from locking out.

Loren