1
I’m developing a data synchronizer, where every five seconds I check for data being synchronized. The synchronization part with the check time every 5 seconds is already working. However, I could not make the progress bar track the progress of the Task, ie, go from 0 to 100 every loop iteration. Follow my code:
 public void timerSincronizacao05Secs() {
    Task sincronizacaoTask05Secs = new Task<Void>() {
        @Override
        protected Void call() throws Exception {
            while (isRunning == false) {
                isRunning = true;
                System.out.println("iniciou  em.....: " + new Date());
                fachada.sincronizarProdutos();
                barraProgresso.setProgress(0.50);
                fachada.sincronizarClientes();
                barraProgresso.setProgress(barraProgresso.getProgress() + 0.50);
                System.out.println("terminou em.....: " + new Date());
                isRunning = false;
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException ex) {
                    break;
                }
            }
            return null;
        }
    };
    lblteste.textProperty().bind(sincronizacaoTask.messageProperty());
    Thread threadSinv05Secs = new Thread(sincronizacaoTask05Secs);
    threadSinv05Secs.setName("Thread sincronização a cada 5 segundos");
    threadSinv05Secs.setDaemon(true);
    threadSinv05Secs.start();
}
I know it’s not the best way to go, but if anyone can help, I’d appreciate it!
Like, at the end of the process it did not Zera the bar again, I tried tbm put a label to inform you what is being updated but tbm did not work. And I don’t know if that’s the way I did it.
– José Allison