A: 

Ok , figured out. A simple mutex did the job.

Thanks to all.

Ziggy