Hi
I’m trying to create a background task in order to refresh a datasource when an external event is occuring and for some reason the task never get executed.
See the code below, I checked that the method creating and scheduling the task for execution is effectively reached.
No errors happen, not sure what i’m doing wrong here.
Michael
@Subscribe public void handleDatasourceChange(EntityChangeEvent e) {
if(!e.getEntityClass().equals(entityClass))
return;
if(frame != null)
frame.showNotification("Need to refresh datasource : "+target, Frame.NotificationType.HUMANIZED);
final BackgroundWorker worker = AppBeans.get(BackgroundWorker.NAME);
BackgroundTask<Void, Void> task = new BackgroundTask<Void, Void>(REFRESH_TIMEOUT_SEC) {
@Override
public Void run(TaskLifeCycle<Void> taskLifeCycle) throws Exception {
if(frame != null)
worker.getUIAccessor().access( () ->
frame.showNotification("Refreshing datasource : "+target,
Frame.NotificationType.HUMANIZED));
worker.getUIAccessor().access(target::refresh);
return null;
}
};
worker.handle(task).execute();
}