Author Topic: VA_StopCommand() - okay to reset _stopVariableToMonitor in VA_Invoke1() ?  (Read 3153 times)

Robertsmania

  • Newbie
  • *
  • Posts: 46
In the plugin sample, there is a boolean variable declared in the class and the VA_StopCommand() will set it to true if the user clicks the button.  But, its never re-set to false in the sample code.

Code: [Select]
        static Boolean _stopVariableToMonitor = false;

        //this function is called from VoiceAttack when the 'stop all commands' button is pressed or a, 'stop all commands' action is called.  this will help you know if processing needs to stop if you have long-running code
        public static void VA_StopCommand()
        {
            _stopVariableToMonitor = true;
        }

Experimentally, it seems to work and make sense to me to re-set the value of _stopVariableToMonitor back to false in VA_Invoke1() but I'd like to know if thats appropriate?  I'm hoping I can trust that Invoke1() being called again after the stop commands had previously been called means the users must be okay running commands again, right?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4781
  • RTFM
Re: VA_StopCommand() - okay to reset _stopVariableToMonitor in VA_Invoke1() ?
« Reply #1 on: February 13, 2022, 04:27:02 PM »
That variable is not part of the plugin API itself, what you do with it is up to you.
If you have no looping or long-running elements in your plugin, and thus have no need for it, you could just remove it entirely; it is not required by VoiceAttack itself.

If you do have those elements, you'd want to make sure that each of the instances that need to make use of that variable, have actually stopped, before resetting the value(s) that are used to stop them.

Having something independent like a call to VA_Invoke1() reset it/them may not guarantee that everything has come to a stop yet, depending on what your plugin actually does. That is for you to know and understand.