从Android上的存储执行时,executeOfflineCommand会跳过命令 [英] executeOfflineCommand skips a command while executing from storage on Android

查看:68
本文介绍了从Android上的存储执行时,executeOfflineCommand会跳过命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在程序中按顺序执行开始和完成命令,并在最后同步所有内容。因此,我先按顺序插入离线命令,并假设它们将以相同的顺序执行。我为此使用了列表和迭代器。

I have to execute "Start" and "Finish" Commands in the Sequential Order in my program and synchronize everything at the end. So I'm inserting the Offline commands in the order first and assuming they will execute in the same order. I'm using "List" with "Iterator" for this.

这里的问题是:在中间的某些奇怪情况下,Finish命令将丢失执行,并且 start命令将彼此相邻执行并发送所有错误的数据并映射它以错误的方式。

Problem here is: Finish Command will be missed execution in some strange scenarios in the middle and "start" commands will execute next to each other and sending all wrong data and mapped it in a wrong way.

由于在服务器上执行命令时操作将获得ID,因此我保留临时ID来将离线命令映射到storage(localID)中。如果我使用其他任何收藏夹,也可以使用List Instaead吗?很难在模拟器上重现此内容。请检查两种情况,并建议该方法在哪里出错。谢谢

As action will get ID when command executes at the server, I'm keeping tempory id's to map the offline commands in storage(localID). Instaead of List if I use anyother collection will this gets any better? It is hard to reproducing this on simulator. Please review both scenarios and advise where can this approaches go wrong. Thanks

我将把OfflineCommands添加到列表中并保存在存储中。之后,该用户可以在App中执行Delete Delete操作,以便我检索列表并从存储中删除已删除的命令,因此现在我已过滤列表。

I will add the OfflineCommands into the List and save in the Storage. After that user can perform delete delete operation in the App so that I will retrieve the list and remove the commands which got deleted from storage so now I have filtered list.

推荐答案

不同步。

这几乎总是Codename One中的一个错误。您的代码处理的是UI,因此应该在EDT上,并且 Display.getInstance()。isEDT()应该为true。

That's nearly always a mistake in Codename One. Your code deals with the UI so it should be on the EDT and Display.getInstance().isEDT() should be true.

我的猜测是中间的命令之一使用以下 invokeAndBlock()派生之一:

My guess is that one of the commands in the middle uses one of the following invokeAndBlock() derivatives:


  • addToQueueAndWait

  • 模式对话框

哪个会触发第二轮同步运行。

Which triggers a second round of synchronization to run.

您可以通过重现问题并检查每次列表中的哪个命令来跟踪此问题。然后修复该命令,使其不会被这种方式阻塞。

You can trace that by reproducing the issue and checking which command in the list is specifically there at each time. Then fix that command so it doesn't block in this way.

另一种修复此命令的方法是在开始处理时立即删除列表,这将防止重复执行命令。

Another approach to fixing it is to remove the list immediately when you start processing which will prevent a duplicate execution of commands.

这篇关于从Android上的存储执行时,executeOfflineCommand会跳过命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆