07-05-2016 05:23 AM
Hi Guys,
I have an issue with NITasks and assessing their state.
Part of my program involves stopping/aborting a task in order to regenerate an output signal and restart the task.
The issue is that after calling analogOutTask.Control(TaskAction.Stop); or analogOutTask.Control(TaskAction.Abort); I am unable to check if the task state. So when I try to write the new samples to the task, I sometimes get a DAQmx.DaqException as the Task is currently in the process of being aborted.
How do I query the state? Or is there a callback for state change?
Thanks
07-07-2016 06:54 AM
Hi Alan,
Have you tried doing a write on the channel, and catching any exception which may(if task is stopped/aborted) be thrown? If an exception is caught then that should tell you the task is in an unwritable/unavailable state, and then you can take action to rectify it.
Let me know your thoughts.
07-07-2016 07:53 AM
Thanks James,
That is what I am doing now, but relying on Try-Catch makes me feel dirty.
If I were able to query the task state I could take action before calling a function I know would throw.