Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

AO cancel

I have a class that creates a AO task that takes some amount of time, n seconds, to complete. I want the user to be able to cancel the AO at any time. But I can't figure out how to do this. I've attached the files of may class, any help would be appreciated. I'm using c#. Thanks.

JMD
Download All
0 Kudos
Message 1 of 2
(3,288 Views)
JMD:

You can abort any DAQmx operation by calling the Task.Control method and specifying TaskAction.Abort. When a task is aborted, it is returned to the Verified state. If the task is running, it is stopped as soon as possible and is then unreserved. After a task has been aborted, you can continue to use the task. However, you might need to transition the task back to its previous state before continuing the specified operation.

I changed your code to use the Task.Control method and wrote a simple WinForms application that uses it. The code is attached. I hope this helps.

Also, I went ahead and made your AO class disposable since the DAQmx Task class is disposable. I don't know how you're using the AO class in your application, but if you
were to create and destroy instances of the AO class in a loop, for example, you would get Task name conflict exceptions from DAQmx unless the Task instance is disposed.

Chris W
NI .NET DAQmx Team
Message 2 of 2
(3,288 Views)