My code is loading connections asynchronously:
runAsync {
controller.loadConnections(viewModel)
} ui {
table.items = it
table.refresh()
}
and inside loadConnections
method:
//read connections from file and then
Platform.runLater(() -> {
CollectionsKt.bind(connections, databases, ConnectionsModel::new);
connections.forEach(connection -> connection.setOwner(viewModel));
});
When I want to add progress bar as:
private val status = TaskStatus()
runAsync(status) {
controller.loadConnections(viewModel)
} ui {
table.items = it
table.refresh()
}
But it blocks the progress indicator. As I understand 2 tasks (progress
and Platform.runLater
) are not executed in async
. But how do I get this to work?
Try this code: