NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
Frank
Posts: 23
0 Kudos

taskHandle TaskHandle *

What's exactly taskHandle pointer?
The first address of memory area where is
stored task?
Active Participant
Mert_A.
Posts: 760
0 Kudos

Re: taskHandle TaskHandle *

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
Member
Frank
Posts: 23
0 Kudos

Re: taskHandle TaskHandle *

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.
Active Participant
Mert_A.
Posts: 760
0 Kudos

Re: taskHandle TaskHandle *

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
Member
Frank
Posts: 23
0 Kudos

Re: taskHandle TaskHandle *

Mert A. ha scritto:

> I hope that's clearer!
Very clear. Thanks a lot for the help.
Member
beth_1
Posts: 1
0 Kudos

Re: taskHandle TaskHandle *

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

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page