mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-24 16:53:37 +00:00
Sync stop operations
This commit is contained in:
parent
025aefea7d
commit
092b16a6dc
1 changed files with 11 additions and 1 deletions
|
@ -74,8 +74,10 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.mail.AuthenticationFailedException;
|
||||
import javax.mail.Folder;
|
||||
|
@ -2321,7 +2323,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
Log.i(account.name + " stop watching operations");
|
||||
final TwoStateOwner _owner = cowner.value;
|
||||
if (_owner != null) {
|
||||
cowner.value = null;
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
getMainHandler().post(new RunnableEx("observe#stop") {
|
||||
@Override
|
||||
public void delegate() {
|
||||
|
@ -2329,9 +2331,17 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
_owner.destroy();
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
} finally {
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
latch.await(5000L, TimeUnit.MILLISECONDS);
|
||||
} catch (InterruptedException ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
}
|
||||
|
||||
// Stop executing operations
|
||||
|
|
Loading…
Reference in a new issue