LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

TSQ read callback not in main thread

I wrote application that use tsq. I've installed read callback which
is executed when there's specified amount of data in the queue. But I
wanted the callback not to run in main thread [which is responsible
for user interface only]. I did it that way:



[...]

CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE,
ReadCallback, NULL, NULL);

[...]


int CVICALLBACK ReadCallback( void *pvData )
{
CmtInstallTSQCallback (giQueueHandle, EVENT_TSQ_ITEMS_IN_QUEUE,
gbyReadBlock, QueueReadCallback, NULL,
CmtGetCurrentThreadID(), &giQueueCallback);

while (gbRunning)
ProcessSystemEvents();
}



QueueReadCallback - does reading form tsq
gbyReadBlock - threshold value



Is there another w
ay to install the callback in secondary thread ?


___________
regards
Frog
0 Kudos
Message 1 of 2
(2,950 Views)
It's fine to put the callback in whatever thread you want, BUT that thread has to be processing events in order to see the events on the TSQ. You can do this in your other thread in two ways, with RunUserInterface (as you see in main), or with a loop that is calling ProcessSystemEvents() until the thread is exited.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 2 of 2
(2,950 Views)