void () { SingleTask task = null; synchronized (LOCK) { closeQueue(); if (myRunningTask != null) { task = myRunningTask; myRunningTask = null; } } if (task != null) { boolean longTimeOut = !ApplicationManager.getApplication().isDispatchThread() || ApplicationManager.getApplication().isUnitTestMode(); try { int timeout; if (longTimeOut) timeout = disposeLongTimeout(); else timeout = 20; task.waitFor(timeout, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException e) { if (!(e.getCause() instanceof ProcessCanceledException)) { LOG.debug(e); } } catch (TimeoutException e) { if (longTimeOut) LOG.warn(formMessage("Wait time out "), e); } } }