Quantcast
Channel: How to refresh a counter on the UI without blocking the rest, in codename one? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How to refresh a counter on the UI without blocking the rest, in codename one?

$
0
0

I try to get a score count on the UI, to be refreshed several times per second. The refresh should not prevent the other elements of the UI from working (Buttons should remain clickable etc.)

I read the doc on the EDT and tried to add a method called from the constructor of the Form:

  private void loopScore() {
        Display.getInstance().callSerially(
                () -> {
                    while (true) {
                        try {
                            MyApplication.score = MyApplication.score + 1;
                            this.gui_Score.setText(String.valueOf(MyApplication.score));
                            Thread.sleep(100);
                        } catch (InterruptedException ex) {
                            //do something
                        }
                    }
                });
    }

But this does not update gui_Score and it blocks the rest of the UI. Help?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>