05-27-2009 09:24 AM
Hi all, we are trying to process incoming TCP data with a callback initiated in a .dll, and it works fine, until there is a Sleep or Delay function called in the main program. The callbacks seems to wait until the end of the delay/Sleep, and only run afterwards. Is there a function where we can enable/prioritize callbacks during delay calls? During the main program the timing is critical, so I would avoid calling ProcessTCPEvents in loop.
Thanks in advance!
05-27-2009 02:25 PM
Hello !
I was able to resolve the same type issue using the following function.
int Sleep(double dblDelay)
{
static double dblTime1;
static double dblTime2;
dblTime1 = Timer();
dblTime2 = Timer();
while ((dblTime2 - dblTime1) < dblDelay)
{
dblTime2 = Timer();
ProcessSystemEvents();
}
return 0;
}
hope it helps you too !
05-29-2009 09:14 AM
network events in the CVI TCP library are implemented using window messages, the same kind of events which signals mouse button clicks or such. thus, for the callback to be called, you must have a running message loop, either by way of RunUserInterface() or by calling ProcessSystemEvents() in a loop.
this specificity of the network library is documented in the help for RegisterTCPServer().
(eventually, NI will one day re-implement their TCP library using events instead of window messages. hint to NI: replace WSAAsyncSelect() by WSAEventSelect()...)
06-01-2009 01:19 AM