From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

taskHandle TaskHandle *

What's exactly taskHandle pointer?
The first address of memory area where is
stored task?
Message 1 of 6
(7,001 Views)
Hi Frank,

A TaskHandle is simply an integral identifier for a particular task.  Nothing more than an ID number, really.  A function like DAQmxCreateTask, which takes a TaskHandle * as an argument is actually storing the new TaskHandle in the pointer that you pass in.  So when a function takes a TaskHandle pointer, it is just asking for the address of some variable you declare.

Hope that answers your question.

Mert A.
National Instruments
0 Kudos
Message 2 of 6
(6,996 Views)
Mert A. ha scritto:

> Hope that answers your question.

Very clear. But was wondering why for DAQmxBaseCreateTask
we pass a pointer to taskHandle... i.e.

DAQmxBaseCreateTask("",&taskHandle);

while for other API C functions like
DAQmxBaseStartTask, DAQmxBaseCreateAIVoltageChan,...
we pass just taskHandle

Thanks again.
0 Kudos
Message 3 of 6
(6,995 Views)
Hi Frank,

When you ask the DAQmx driver to create a task for you (via DAQmxBaseCreateTask or DAQmxCreateTask), it does so, and it assigns an ID number (the TaskHandle) to the new task.  The way DAQmx gives that number back to you, is by having you pass in a pointer into which it can write that new ID number.

TaskHandle handle1 = -1, handle2 = -1;

DAQmxBaseCreateTask ("task1", &handle1); /* changes the value of handle1 */
DAQmxBaseCreateTask ("task2", &handle2); /* changes the value of handle2 */

DAQmxBaseCreateAIVoltageChan (handle1, ...); /* specifies to add the channel to the task named "task1" */
DAQmxBaseCreateAIVoltageChan (handle2, ...); /* specifies to add the channel to the task named "task2" */

This allows you to have multiple tasks configured/running at a time, because functions like DAQmxBaseCreateAIVoltageChan take the handle of the task you want to create the channel in.  You don't have to pass a pointer to the TaskHandle to most functions, because they only need to read the value, not actually write to it, like DAQmxBaseCreateTask does.

I hope that's clearer!

Mert A.
National Instruments
0 Kudos
Message 4 of 6
(6,992 Views)
Mert A. ha scritto:

> I hope that's clearer!
Very clear. Thanks a lot for the help.
0 Kudos
Message 5 of 6
(6,988 Views)

Hello,

 

I am trying to use NIDAQmx.h in a C++ file, and creating a continuous signal when an event occurs in C#. However, I am not able to stop the continous loop. In order to stop it, I need to return TaskHandle to C# (which is not possible since NIDAQmx.h is not available for C#). So, from what I have read, can I cast it to an integer and then cast it back to Taskhandle?

 

Thank you,

Beth

0 Kudos
Message 6 of 6
(5,574 Views)