Limit number of running threads with NewNamedSemaphore and GetSemaphore example

If the Semaphore only needs visibility inside the one EXE it does NOT need a Name so you could use NewSemaphore(LONG initial=0,LONG max=1). That way you have no possible name issues and the OS does not need to manage your named object.

You could probably do this simpler with a Global Long protected by a Critical Section, or Vista added the Slim Reader Write lock.

I was thinking of your other post: