mainFrame().addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent evt)
{
retrieveItems();
closeAllConnections();
System.exit(0);
}
});
For the code above, retrieveItems()
executes nicely but there is a Background Task called doBackup()
that's inside closeAllConnections()
which does not execute at all. The program just seems to skip the task. Here is a brief view of what closeAllConnections()
contains;
public void closeAllConnections()
{
boolean shouldBackup = getBackupOnCloseStatus();
if(shouldBackup)
{
doBackUp();
}
dbManager.disconnectDB();
}
After using the Netbeans Step-Debugger, I noticed that the program execution does not even enter the doBackup()
method before application exits. This is strange. I would highly appreciate any help as regards what might be causing this behaviour. Thanks good people!
Just if this piece of extra info might be helpful in finding a solution, I'm using Swing Application Framework, so the the Task doBackup()
looks like the following...
@Action
public Task doBackUp()
{
return new DoBackUpTask(getApplication());
}
private class DoBackUpTask extends org.jdesktop.application.Task<Object, Void>
{
private boolean done = false;
DoBackUpTask(org.jdesktop.application.Application app)
{
super(app);
this.setMessage("Backing-up database...");
}
@Override
protected Object doInBackground()
{
File destDir = new File(appManager.getBackUpDir());
done = backUpDataBase(destDir);
return null;
}
@Override
protected void succeeded(Object result)
{
if(done)
{
setMessage("BackUp completed.");
}
}
}