ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

NITask State

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

0 Kudos
Message 1 of 3
(4,584 Views)

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.

James Kent | Applications Engineer | National Instruments UK & Ireland
w: uk.ni.com | ireland.ni.com
0 Kudos
Message 2 of 3
(4,553 Views)

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.

0 Kudos
Message 3 of 3
(4,550 Views)