This content has been marked as final. Show 4 replies
To me, the simplest solution would be to make the dialog modal, and not to dismiss it until the database update is complete. This would prevent them going back to the main window at all. You can do fun stuff like binding the disable property of any "OK" and "Cancel" type buttons to the running property of the task that updates the database.
But perhaps this is too restrictive; for example, do you want the user to be able to interact with other parts of the UI while the update is progressing?
Honestly I just hadn't thought of something that simple.
If I did that would there be any real reason to use a background task, since I want the task to complete anyway?
I wondered that after I'd posted it.
I guess I still think it's good practice to put the database update in a background task. It's easy enough to do so, you get all the nice semantics of task.setOnSucceeded(...) and task.setOnFailed(...) that nicely encapsulate the fact that you're waiting for a process to do something, and you'd be properly set up if you decided to add any other functionality in there. Also, if you're blocking the FX Application thread, you'll likely get strange results if you cover and then uncover your application with a different window (your application might not get the opportunity to repaint).
I went with your suggestion and it works fine now, Thanks!