It is happening something that I can not understand. When I run a function which injects 100 pulses (using external electronics...) from my main program it works properly but When I do the same using a function like (thread function):
DWORD WINAPI ThreadClass::ThreadFunc(LPVOID pvParam)

It goes crazy and injects less that what I expect. I have realized that it has something to do with time...because when I write Sleep(10) for example, it works better !!

Anyone knows why it happens???

Thanks,