Task States
- Updated2023-02-17
- 2 minute(s) read
Task States
You do not need to explicitly change the state of a Task because NI-DAQmx tasks automatically transition from one state to another as necessary. However, you can explicitly modify the state of a Task. In some cases, explicitly managing when state transitions occur might result in improved performance. In the NI-DAQmx .NET library, you can change the state of the task by calling the Control method with a value that indicates the new state, as shown in the following example:
VB.NET
myTask.Control(TaskAction.Verify)
C#
myTask.Control(TaskAction.Verify);
This example moves the task into the verified state. Refer to Explicit Versus Implicit State Transitions for a description of when Task state transitions occur and when you might want to explicitly manage them, and refer to Task State Model for the task state order and a description of each state.
Verified Tasks
In the NI-DAQmx library, you cannot query the value of most properties of a Task until that task is verified. If you attempt to query a property value before the task is verified, a DaqException is thrown. The NI-DAQmx driver sets many properties to default values that are dynamically determined from the values of other properties. The driver cannot calculate these default values until it knows all the properties values for a specific Task. Verifying a task involves examining all of the properties that are associated with a Task and can be time-consuming.
Because the Task is not verified when properties are set, you might be able to set a property to an invalid value. However, an exception is not thrown until later in the program because some validity and consistency checks are performed on properties after the Task is verified. Use the Control method to verify the Task.