mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-25 17:27:00 +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.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import javax.mail.AuthenticationFailedException;
|
import javax.mail.AuthenticationFailedException;
|
||||||
import javax.mail.Folder;
|
import javax.mail.Folder;
|
||||||
|
@ -2321,7 +2323,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||||
Log.i(account.name + " stop watching operations");
|
Log.i(account.name + " stop watching operations");
|
||||||
final TwoStateOwner _owner = cowner.value;
|
final TwoStateOwner _owner = cowner.value;
|
||||||
if (_owner != null) {
|
if (_owner != null) {
|
||||||
cowner.value = null;
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
getMainHandler().post(new RunnableEx("observe#stop") {
|
getMainHandler().post(new RunnableEx("observe#stop") {
|
||||||
@Override
|
@Override
|
||||||
public void delegate() {
|
public void delegate() {
|
||||||
|
@ -2329,9 +2331,17 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||||
_owner.destroy();
|
_owner.destroy();
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
Log.e(ex);
|
Log.e(ex);
|
||||||
|
} finally {
|
||||||
|
latch.countDown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
latch.await(5000L, TimeUnit.MILLISECONDS);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
Log.w(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop executing operations
|
// Stop executing operations
|
||||||
|
|
Loading…
Reference in a new issue