new Thread(new Runnable() {
public void run() {
while (true) {
try { Thread.sleep(1000); } catch (Exception e) { }
Display.getDefault().asyncExec(new Runnable() {
public void run() {
... do any work that updates the screen ...
}
}
}
}
}).start();
Ok, but the case is different in our case in the way that we already have actionPerformed method and the update has to be perfomed after getting the value from the database every one second or so. So, in above case, we dont need to create different thread, nor we need code for the timer. So, in our project, this will look something like this:
performDbConnection();
final long f = dataBase.returnNoOfDataset();
// this will only use the current display
try
{
Display.getDefault().asyncExec (new Runnable ()
{
public void run ()
{
series.addOrUpdate(new Millisecond(), f);
}
});
}
catch(Exception E)
{
System.out.println("Exception while updating the chart dynamically: " + e.toString() + "\n");
}
No comments:
Post a Comment