Asynchronous calls inside the EDT can be made by calling the doLater{}
method. This method simply posts a new event to the underlying EventQueue using SwingUtilities.invokeLater
, meaning you spare a few characters and a class import.Example:class MyController {
def model def action1 = {
// will be invoked inside the EDT by default (pre 0.9.2)
def value = model.value
Thread.start {
// do some calculations
doLater {
// back inside the EDT
model.result = …
}
}
} def action2 = {
// will be invoked outside of the EDT by default (post 0.9.2)
def value = model.value
// do some calculations
doLater {
// back inside the EDT
model.result = …
}
}
}