When should you perform explicit state transitions, and when should you rely on the task to perform implicit state transitions?
The answer depends on your application. The following list identifies instances in which you should use explicit state transitions:
- Verify—If in your application users interactively configure a task by setting various channel, timing, and triggering attributes/properties,
explicitly verify the task occasionally to inform the users if they have set an attribute/property to an invalid value.
- Reserve—If the following is true, explicitly reserve a task: your application contains many different tasks that use the same set
of resources, one of these tasks repeatedly performs its operation, and you want to ensure that none of the other tasks acquires
these resources after the task begins its sequence of operations. Reserving the task exclusively acquires the resources that
the task uses, ensuring that other tasks cannot acquire these resources. For example, if your application contains two tasks
that each perform a sequence of measurements and you want to ensure that each sequence is completed before the other sequence
begins, you can explicitly reserve each task before it begins its sequence of measurements.
- Commit—If your application performs multiple measurements or generations by repeatedly starting and stopping a task, explicitly commit
a task. Committing the task exclusively acquires the resources that the task uses and programs some of the settings for these
resources. By explicitly committing the task, these operations are performed once, not each time the task is started, which
can considerably decrease the time needed to start your task. For example, if your application repeatedly performs finite,
hardware-timed measurements, the time required to start the task can dramatically decrease if you explicitly commit the task
before repeatedly performing these measurements. Explicitly committing a task also is required if you need to perform additional
read operations of the samples acquired by the task after stopping the task. For more information, refer to Using the Start
- Start—If your application repeatedly performs read or write operations, explicitly start a task. Starting the task reserves the
resources that the task uses, programs some of the settings for these resources, and begins to perform the specified operation.
By explicitly starting the task, these operations are performed once, not each time the read or write operation is performed.
This process can considerably decrease the time required to perform each read or write operation. For example, if your application
repeatedly performs single-sample, software-timed read operations, the time required for each read operation can dramatically
decrease if you explicitly start the task before repeatedly performing these read operations.