RuffyScripter: wait for command thread to finish up.
This commit is contained in:
parent
51b51c159c
commit
1cbfefffb8
1 changed files with 10 additions and 1 deletions
|
@ -231,12 +231,13 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (RuffyScripter.class) {
|
synchronized (RuffyScripter.class) {
|
||||||
|
Thread cmdThread = null;
|
||||||
try {
|
try {
|
||||||
activeCmd = cmd;
|
activeCmd = cmd;
|
||||||
long connectStart = System.currentTimeMillis();
|
long connectStart = System.currentTimeMillis();
|
||||||
ensureConnected();
|
ensureConnected();
|
||||||
log.debug("Connection ready to execute cmd " + cmd);
|
log.debug("Connection ready to execute cmd " + cmd);
|
||||||
Thread cmdThread = new Thread(() -> {
|
cmdThread = new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
if (!runPreCommandChecks(cmd)) {
|
if (!runPreCommandChecks(cmd)) {
|
||||||
return;
|
return;
|
||||||
|
@ -323,6 +324,14 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
if (activeCmd.getResult().success && menu != null && menu.getType() != MenuType.MAIN_MENU) {
|
if (activeCmd.getResult().success && menu != null && menu.getType() != MenuType.MAIN_MENU) {
|
||||||
log.warn("Command " + activeCmd + " successful, but finished leaving pump on menu " + getCurrentMenuName());
|
log.warn("Command " + activeCmd + " successful, but finished leaving pump on menu " + getCurrentMenuName());
|
||||||
}
|
}
|
||||||
|
if (cmdThread != null) {
|
||||||
|
try {
|
||||||
|
// let command thread finish updating activeCmd var
|
||||||
|
cmdThread.join(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
activeCmd = null;
|
activeCmd = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue