Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Are callbacks re-entrant in DAQmx?

I'm writing some C# code using one or more cDAQ modules to acquire data at different samples rates from each. The code determines the number of cDAQ modules required and creates an instance of the "Task" class for each and stores it in an ArrayList along with other parameters that control the acquisition for that module. When started, each Task is started and run with an analogInReader.BeginReadMultiSample request with the IAsyncResult argument set to call the callback routine with the calling task element in the ArrayList as an argument. This allows the callback to correctly retreive and process the data from that module and re-schedule the callback for more data if required.

 

All Tasks therefore use the same callback routine and there is nothing to stop one or more Tasks calling the callback at the same time. My question is "If a callback is written with no local storage are they re-entrant or are they externally blocked and queued?" If not, to get a single callback function to work with multiple task in this manner do I have to Mutex it to guarantee that it is completed before being re-run? Results obtained so far debugging within the VS 2010 environment on .NET 3.5 have been inconclusive but generally result in inconsistent behaviour.

 

Any confirmantion as to how callback routines operate in this mode would be appreciated.

0 Kudos
Message 1 of 2
(3,073 Views)

Hello Vibrate,

 

I’m unsure as to exactly what you are trying to achieve, from what I understand you have multiple DAQ tasks in an array all of which are setup to have different rates channels etc. And you are calling these tasks by indexing the array to pull the specific task you require at any one time?

 

As for tasks being re-entrant, no they are not. Once you set a task on a DAQ system it will lock that module or port until the task has performed its operation or the task has been stopped AND cleared. If you are attempting to call a task that uses the same port while another task is running it will error and fail. What I would suggest you do is setup a cue based system that runs and closes each DAQ task before calling the next, you should be able to run two loops in parallel  (hyper thread) that will each execute a separate task on a separate channel so you are able to pull data at a faster rate.

Regards

Andrew George @ NI UK
0 Kudos
Message 2 of 2
(3,057 Views)