Reply To: OnInterrupt callback in ActionTask

Forums 💬 NodeCanvas ⚙️ Support OnInterrupt callback in ActionTask Reply To: OnInterrupt callback in ActionTask

#17155
Gavalakis
Keymaster

    Hey,

    Indeed, we could implement an interrupt callback and I think that makes sense (although never used personally before) 🙂
    Instead of a separate callback though, I think that it would be better to provide an argument to the OnStop callback (bool interrupted), so that in code you can discern whether the OnStop was called due to interruption or not, instead of calling both OnStop and OnInterrupt.
    Here are the changes to make please:

    1) Change the final line of the EndAction method to this:

    2) Add this new OnStop method. We can’t change the existing one due to backwards compatibility.

    This way, you can either override OnStop as before (and thus all existing tasks will still work), or override the OnStop(bool interrupted) method, if you care to know about the interruption in your action task.

    Let me know if that works for you.
    Thanks!