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.