From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Previously aborted read task blocks when stopping another read operation

Hi,

 

my application uses an analog input task with several voltage measurement channels. There are two distinct states during which different read operations (types of measurement) should be performed. For the first, I want to read samples continuously until it is explicitly stopped, for the second, I want to read a predetermined fixed number of samples only. When transitioning from the first to the second state, the continuous read operation is stopped and the task is reconfigured to read a finite number of samples. Same in the other direction after the finite acquisition is done.

 

The following problem arises: the finite acquisition is taking a while so I want a cancel option. When the user triggers a cancel, the AI task is aborted via calling task.Control(TaskAction.Abort) since this is the only way to immediately stop an acquisition in progress. The thread that was performing the read then catches the exception that is triggered upon aborting the task and (attempts to?) reset the task by calling task.Control(TaskAction.Stop), since this is what you should do to recover the task after aborting according to the documentation, I quote: "... To recover the task, use NationalInstruments.DAQmx.Task.Start to restart the task or use NationalInstruments.DAQmx.Task.Stop to reset the task without starting it."

After this, the SW shall return to the first state, i.e. resume the continuous acquisition. Up until now everything is working fine, even the continuous acquisition is working perfectly, *until* the moment I want to stop it again, when it inexplicably blocks at calling task.Control(TaskAction.Stop) forever. The whole SW hangs and the only way to close it is via task manager (or the visual studio stop button).

 

This only happens if the task has been aborted before, despite having reset it afterwards. It also does not happen when the finite acquisition is allowed to complete so I can rule out a task misconfiguration in between switching states.

 

I'm at a loss to explain this behaviour and would greatly appreciate some help.

 

Edit: just realized that it even blocks at task.Dispose(), so I can't even re-create the task to solve the problem...

0 Kudos
Message 1 of 1
(802 Views)