pause port scanning while a job is running

This commit is contained in:
Matthew Kennedy 2023-11-02 20:38:01 -07:00
parent 6fe13904af
commit a82bb10a71
2 changed files with 8 additions and 3 deletions

View File

@ -84,7 +84,7 @@ public enum SerialPortScanner {
}
}
private volatile boolean isRunning = true;
private volatile boolean isRunning = false;
private final Object lock = new Object();
private AvailableHardware knownHardware = null;
@ -204,7 +204,8 @@ public enum SerialPortScanner {
}
}
private void startTimer() {
public void startTimer() {
isRunning = true;
Thread portsScanner = new Thread(() -> {
boolean isFirstTime = true;
while (isRunning) {

View File

@ -112,7 +112,11 @@ public class ProgramSelector {
final UpdateOperationCallbacks callbacks = new UpdateStatusWindow(appendBundleName(jobName + " " + Launcher.CONSOLE_VERSION));
final Consumer<UpdateOperationCallbacks> job2 = job;
ExecHelper.submitAction(() -> job2.accept(callbacks), "mx");
ExecHelper.submitAction(() -> {
SerialPortScanner.INSTANCE.stopTimer();
job2.accept(callbacks);
SerialPortScanner.INSTANCE.startTimer();
}, "mx");
}
});
}