0

I have set MessageCountListener for IMAPFolder. In order to get updates continuously I had to do the following, which is a killer for my app performance wise. It freezes the GUI since it's running for each and every folder.

while (true) {
     try {
          if (folder != null && folder.isOpen()) {
              folder.idle();
          } else {
              getSyncListenersAttachedFolders().remove(syncFolder.getFolderID());
          }
     } catch (Exception ex) {
          errorLOG.error("IDLE command issue exception.");
          getSyncListenersAttachedFolders().remove(syncFolder.getFolderID());
     }
}

Is there any better way of issuing idle command which will not run in a while(true) condition. Expecting a quick response. Thanks in advance.

Priyan Perera
  • 469
  • 1
  • 8
  • 13

1 Answers1

1

You need to run it in its own thread.

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – Styxxy Feb 22 '13 at 19:44
  • But that is the answer. The way you're expected to use the idle command is to run it in a loop, and because of that you should not run it in the GUI thread but rather in a thread of its own. – Bill Shannon Feb 23 '13 at 00:23
  • You could have been a little more descriptive in yiu answer, explaining what was wrong and how to fix it. – Styxxy Feb 23 '13 at 09:23