Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Actors shut down, but classes still locked EXAMPLE SOLUTION

Hi all, 

So one of the most annoying bugs I've encountered in my code since starting to use AF has been the situation where, after exiting the application, some actor somewhere is still running requiring me to close the project and get that "some VIs are still running" dialog.  Annoying, right?  Well I finally figured out (I think) what I was doing wrong, and it has to do with error handling.   

In an actor that has a loop inside its actor core, if an error occurs in PreLaunch Init or before this loop and gets passed to the Actor Core call parent, the actor core will simply not execute.  This means your Handle Error will never be called, and your Stop Core will never be called.  If the loop in your actor core has an event handler with no timeout, that loop will never be able to handle the error either, leaving that loop stranded!  This causes the above headache, and I'm sure I'm not the only one who's encountered it.  So I made a little example app to demonstrate the issue and my solution.  Unzip the Hanging Actor Example.7z file and open the project.  Run Launch App.vi to see what happens.   

I often encounter this problem in data producers, which typically run without their own display and just loop over some daq task (daqmx or OPC, for example) since these all have some piece of hardware they have to initialize before the inner loop can start.  Please let me know your thoughts on what I'm doing here. I use this pattern everywhere so if there's a better way to do it I'm all ears!

CLAD
Download All
0 Kudos
Message 1 of 3
(3,343 Views)

I think the issue you're seeing is that the error you're generating in Problem Actor's Actore Core is changing how your helper loop executes:

-Passing an error into the "Create User Event" function stops it from creating a user event

-Passing an error into the "Register for Events" function stops it from registering for events

-The Problem Actor's stop core is executed, but as coded the user event reference is invalid and the event structure never started listening to that event, so it doesn't stop!

Changing the problem actor's actor core to look like this fixes your issue:

problem actor actor core.png

If an error is generated in pre-launch init the "Launch Nested Actor" VI returns the error directly and the actor is never launched.

My conclusion here is that you should make sure to not pass errors into functions related to how your helper loops stop!

Craig H. | CLA CTA CLED | Applications Engineer | NI Employee 2012-2023
Message 2 of 3
(2,941 Views)

Ah yes the actor core does call Stop.vi if an error is passed into it. So it would be cleaner to do as you say.  Thanks!

CLAD
Message 3 of 3
(2,941 Views)