JFXStudio: sketch, hack, share

Asynchronous operations in JavaFX

Posted by: surikov on: June 9, 2009

Example requests Google Path API in asynchronous mode. Look to time ticker. The time doesn’t stop while application make request to server

.

Start example via WebStart – http://www.javafx.me/crudfx/examples/Asynchronous.jnlp

.

How to use:

import crudfx.util.*;
...
Waiter{
  action:makeQuery
  onDone:updateGUI
  }.serve();

.

Download Netbeans project
http://www.javafx.me/crudfx/examples/Asynchronous.zip

Download CRUDfx SDK
http://www.javafx.me/crudfx/extension/CRUDfx.jar

7 Responses to "Asynchronous operations in JavaFX"

[...] Asynchronous operations in JavaFX Posted June 9, 2009 [...]

I wrote as a blog about asyn in JavaFX 1.2 at
http://blogs.sun.com/baechul/entry/javafx_1_2_async
Hope this help someone.

What is the Waiter class? The code doesn’t compile.

hi , thanks for the nice post !

i have a question: is it OK to update javaFX variables (like var result in here) from within your Waiter.action() function ?

I am asking casue I heard that this is not recommended and may lead to some kind of instability due to unreported concurrent modifications..

thanks in advance !

NO!!!!

Update GUI from onDone only. I used this in 2 real projects (real projects not useless toys from javafx.com). It works fine.

Thanks for your quick answer !

so there is a difference between updating a javaFX Model variable and updating a javaFX View variable…

The only difference i see there is that the latter one is currently in the scenegraph and i assume now that as soon as some fields of the Model are bound directly to the View components – things get ugly if the model is updated again by some other request of others parts of the programm and i can get around that’s through using the “var parsedResult” as a duplication of the model “var results” which you then can bind to the view. just not straightforward but if you say it works for you, that’s fine !

thank you very much for helping me to get a better understanding on that !

Leave a Reply

Challenge: Small is the New Big

This month's challenge: code something cool in only 30 lines, using the theme of Holiday. Ends December 15th.

Tags