Author Topic: Question about VC.Pause and commands with ++  (Read 1960 times)

0 Members and 1 Guest are viewing this topic.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Question about VC.Pause and commands with ++
« on: June 17, 2016, 10:17:00 AM »
as far as I know that commands that starts with ++ will run in a separate thread ...

my question if a command with ++ triggered then the main command issued vc.pause ... will the ++command pause as well? I tried to test but couldn't reach a solid conclusion.
When Voice command gets tough, use hand gestures

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Question about VC.Pause and commands with ++
« Reply #1 on: June 17, 2016, 12:33:59 PM »
Yup, your suspicions are correct. If the main command has a VC.Pause action, it will also delay the ++ command for that same duration.

The main thing to remember is that VC.Pause should not be used for significant pauses, and whenever this is unavoidable, that command should use the ++ (unless, for some reason, users want to freeze all commands for that duration).

This is why we try to alert users in the action description for VC.Pause:

Quote
Pauses execution of the macro. Parameter is in milliseconds.  (1000 = 1 second).
Warning: This will freeze VoxCommando. You should only use this for short pauses.

Here is a pretty good demonstration of the VC.Pause behaviour that you mentioned, for those curious to try it out. Execute the ++ command immediately followed by the "other" command:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.1.9-->
<commandGroup open="True" name="testing pause" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="177" name="++Test Pause" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>I will now pause for 5 seconds ...</param>
        <param>5000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>5000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.AddText</cmdType>
      <params>
        <param>5 seconds have passed</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Test Pause</phrase>
  </command>
  <command id="186" name="This is another command" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>This is another command.</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>10000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>Main command. 10 seconds have passed.</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>This is another command</phrase>
  </command>
</commandGroup>
« Last Edit: June 17, 2016, 12:36:08 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Question about VC.Pause and commands with ++
« Reply #2 on: June 17, 2016, 01:01:33 PM »
I assume that when you say "main command" you just mean some other, normal, non ++ command. I think this will only be an issue if the duration of the pause in the non ++ command is longer than the pause in the ++ command.

It might help to understand that ALL actions (except for VC.Pause) must run on the main UI thread.  Anything that happens between actions such as updating the history window must also be performed on the main UI thread, because it is interacting with the UI in order to show you stuff.  So looking at the ++ command, the first action following the VC.Pause action will not be able to execute until any other commands that are hogging the UI thread are finished and release the thread so others can use it.

But as Nime5ter points out, it's not really an issue since you should not be using long pauses anyway, and if you do need them they should be put into a ++ command.
« Last Edit: June 17, 2016, 01:03:45 PM by jitterjames »

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Question about VC.Pause and commands with ++
« Reply #3 on: June 17, 2016, 03:26:22 PM »
I run the commands, I think I got what is going on ... if I rephrase it; the pause in the main thread (commands with no ++) will pause everything .... while a pause in the branched thread (command with ++) will affect only that branch ...
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Question about VC.Pause and commands with ++
« Reply #4 on: June 17, 2016, 06:00:42 PM »
Yes, but only if the pause in the main thread is longer than the pause in the ++ command.  Otherwise it has no effect.  The pause is not "added" to the ++ command, but if the ++ pause finishes before the pause in the regular command then it will be stuck waiting for it to finish before it can continue to the next action.