Background task not executed

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();
        }

My bad, solved.
Misuse of the BackgroundTask : I had an exception complaining - on purpose - that I accessed UI thread from a background task by calling worker.getUIAcessor().
I simply got the UIAccessor while within the UI thread and used it later in the event handler method.
As the UIAccessor already provides async processing, no need to do more.
BTW, the log explorer is very handy.
Michael


        @Subscribe
        public void handleDatasourceChange(EntityChangeEvent e) {
            if (!e.getEntityClass().equals(entityClass))
                return;
            uiAccessor.access(() -> {
                if (frame != null)
                    frame.showNotification("Refreshing datasource : " + target,
                            Frame.NotificationType.HUMANIZED);
                target.refresh();
            });
        }

Hi,

you are right.

Method BackgroundWorker.getUIAccessor is annotated with @ExecutedOnUIThread which means that it can be invoked only from UI thread.

Yup, so I started to use this annotation in my code also. Handy.

Please note that it is only for documentation purpose. We don’t track illegal access from background threads for your code.

Yes the docs are clear on that, thanks.