NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Wait ms function in C#

I tried to use a part of the code for Wait functionality from an example code using .NET, but when I tried to use it, the delay did not work.

The code (C:\Users\Public\Documents\National Instruments\TestStand 2020 (64-bit)\Examples\NI_SemiconductorModule\Accelerometer):

 

private static void Wait(double timeInSeconds)
{
      // Thread.Sleep() has a resolution over 10ms, so use Stopwatch to support shorter settling times.
      if (timeInSeconds > 0.0)
      {

           Stopwatch stopwatch = Stopwatch.StartNew();

           double frequency = Stopwatch.Frequency;
           while (true)
           {
               double elapsedSeconds = stopwatch.ElapsedTicks / frequency;
               if (elapsedSeconds < timeInSeconds)
                 {
                   break;
                 }
            }
        }
}

I hope you can help me. Thank youuu

 

0 Kudos
Message 1 of 5
(177 Views)

This seems TestStand related but you are posting in the LabVIEW forum. Not sure how active the TestStand forum is nowadays, but you likely won't get any more reactions here.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 5
(131 Views)

Hi dog,

 

what's wrong with using an ordinary Wait step?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 5
(121 Views)

For example, I tried to put a delay of 2 seconds before the measurement using an Pxie-4139 and two seconds delay before displaying the measured value, but when I run the program, it happened so fast as if there are no delays.

0 Kudos
Message 4 of 5
(78 Views)

Hi dog,

 


@theblackdog wrote:

I tried to put a delay of 2 seconds before the measurement using an Pxie-4139 and two seconds delay before displaying the measured value, but when I run the program, it happened so fast as if there are no delays.


When I place wait steps then they (most often) do what I expect them to do:

The LimitTests show the elapsed time since "Statement" expression…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 5
(54 Views)