title: javafx 8 dialog and concurrency
body: <p>I want to show a custom JavaFX 8 dialog to a user, capture data from the user and then close the dialog after the data is saved to the database (or shows an error message\alert).</p>
  
  <p>At the moment, the dialog is shown with the following code:</p>
  
  <pre><code>Optional&lt;MyType&gt; result = dialog.showAndWait();
  </code></pre>
  
  <p>Followed by code:</p>
  
  <pre><code>myrepository.save(result)
  </code></pre>
  
  <p>From reading the documentation, it looks like instead I should perform this repository.save in a background Task? </p>
  
  <p>It looks like this code could only be executed after <code>showAndWait();</code> and couldn't close the standard dialog as this would need to be done on the JavaFX application thread?</p>
  
  <p>Is there a way to only show the dialog, save the data, and then show a confirmation dialog only if the database save succeeds on the background Task?</p>