What to do when UI is not attached?

Hi everyone!

I have the following situation. In my app i update some controls values periodically using Java’s TimerTask.
The updation method looks like this:

[code]
public void updateDates() {

if(!myUI.get().isAttached())
    return;

myUI.get().access(() -> {
    isAsyncUpdate = true;
    resetUnmodified();
    isAsyncUpdate = false;
    myUI.get().push();
});

}
[/code]Ok, once the user logs in everything is being update w/o any problems. Assume that user logs out and then the same user logs in. And after that the isAttached() method return false.
I can’t understand why this happens and how to overcome this(
How can I resolve this issue?

Thanks in advance for any help

where are you creating your timer ?

an ui will be detached when the page is close or refresh.

maybe you should remove your timer when the ui detached.

you can override the detach method in ui to do that.

@Override
    public void detach() {    
        //your code for closing you timer

        super.detach();    //DONT REMOVE THAT    
    }

Hi Alain!

Thanks a lot for the suggestion. I refactored some classes and issue, it seems, passed away.

Thanks for your assist.