From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

AccessViolationException using DigitalSingleChannelWriter.WriteSingleSampleSingleLine

Hi,

 

Sometimes I get a System.AccessViolationException, here is the C# code:

StopTask(tsk);
tsk.Timing.SampleTimingType = SampleTimingType.OnDemand;
DigitalSingleChannelWriter writer = new DigitalSingleChannelWriter(tsk.Stream);
writer.WriteSingleSampleSingleLine(true, data);

This happens, if the Task "tsk" has done other actions (waveform output) before calling the StopTask.

 

I already found a solution for this: calling

tsk.Control(TaskAction.Verify); 

 after stopping the task.

 

I'm lucky to have a solution, but now I want to understand what is happening here:

- what exactly is TaskAction.Verify doing?

- is it a good practice to call TaskAction.Verify after every TaskAction.Stop every time? Are there any risks?

 

Thanks,

Jochen

0 Kudos
Message 1 of 2
(3,165 Views)

Hello Jochen,

 

Have you had a chance to review this info?

__________________________________________
The best way to thank, is to give KUDOS
0 Kudos
Message 2 of 2
(1,697 Views)