NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

TestStand gets hung up after running a test that contains a new thread

Solved!
Go to solution

TestStand is getting hung up at the end of my test.  I'm trying to kick off a new test thread.  All that thread does is call the TestFunction() in my c++ dll.  I have another function that is called in my main test that is using a function in the same dll called StopTestFunction().  When StopTestFunction is run it sets a global variable to false which should cause the thread to finish since TestFunction() will finish.  Once TestStand gets through the test it simply gets hung up at the end and I have to kill the application with task manager.  Am I doing something wrong when I create the test thread?  I attached an image of the sequence and some code with the functions mentioned above.

Download All
0 Kudos
Message 1 of 3
(2,770 Views)
Solution
Accepted by topic author BCH63

I see two reasons this is happening:

 

  1.  Your code snipit shows:
    while (doListen = true)
    This is an assignment operation, so this will always be true and this loop will never stop. Comparison would be:
    while (doListen == true)
  2. Even fixing that, this snipit is going to starve the thread:
    while (doListen == true)
    {
     number ++;
    }
    
    This is counting as fast as possible in a loop and will not stop to process other events.

If you're wanting to run something continuously in the background and stop it from a different thread in TestStand, I recommend two things:

 

  1. Use notifier or other sync object when you need to communicate between threads (like sending a stop notification).
  2. Use Termination Monitor so you can stop the loop without killing the whole process if something goes wrong.

Hope this helps,

Trent

 

 

https://www.linkedin.com/in/trentweaver
0 Kudos
Message 2 of 3
(2,698 Views)

Thanks for catching the missing ''==" I didn't even realize that I did that.  I will try using a sync object and or Termination Monitor.  I havn't had to use those before, thank you.

0 Kudos
Message 3 of 3
(2,660 Views)