LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

PostDeferredCall sending and extracting data

Hi all,

i am in need of some quidence, or an example of using the PostDeferredCall to pass multiple vaiables, or if it is even possible.

say for example i have a table and i want to recieve the eventdata1 and event data2 parameters from the event callback how do i send the two parameters in the function and then when i am in the deferred function extract the two parameters?

Message 1 of 2
(3,519 Views)

PostDeferredCall allows you to pass a pointer to the callback function.  If you need to pass more than one item, the easiest solution is to create a structure that has all the items that you need contained in it, and pass the pointer to that structure to the deferred function callback (though, in your example you could just use an int array and pass the pointer to that).  Note that when the deferred function executes, that structure must still exist in memory somewhere, so you can't just pass the memory address of a local variable.  If you are going to have multiple deferred calls queued up at once, I've found it's best to malloc some memory for the structure, pass the pointer to the malloc'd memory, and then you can free it when you're done with it, possibly in the callback function itself.  Hope this helps.

Message 2 of 2
(3,506 Views)