LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Running the TSQCallback function in a different thread?

Hi,

I am looking at the example code directPtrAccess.c where the TSQcallback function is set to be executed in the same thread that generates the data. However, in application, I would like to run the call back function in a separate thread.

 

I would greatly appreciate if some one can clarify whether this is possible and if yes how it should be done?

 

Thanks!

 

Sripad

 

 

 

0 Kudos
Message 1 of 2
(2,750 Views)

In that example the TSQ callback is not executed in the generation thread: it is executed in the main thread instead.

The generation thread is unknown (the thread ID is not saved in any variable) but is it different from the main thread, which is the one that handles the user interface.

 

As you can see, the TSQ callbacl is installed receiving CmtGetCurrentThreadID() in Callback Thread ID; that is to say, it receives the ID of the main thread and executes there.This is a very common situation, where generation / acquisition of data and other tasks are executed in a separate thread and presentation of data and UI handling are executed in the main thread.

 

If you had previously created a different thread and saved its ID, you could pass it in this parameter and obtain the callback to run in that thread.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 2
(2,733 Views)