Flex:取消 HTTPService.send()?
好的,我有一个 HTTPService
,只要从 send() 调用获取结果,它就会执行 dataLoaded(e:ResultEvent):void
函数。
好的,如果我调用 HTTPService.send()
,然后在前一个收到结果之前再次调用 HTTPService.send()
,我最终会重复运行 dataLoaded ()
这是不受欢迎的
我想要的是如果 HTTPService.send()
在之前的调用返回结果之前被调用。我想取消第一次调用,只处理最后一次调用 HTTPService.send()
的结果,
我希望这是有意义的。
我怎样才能做到这一点?
谢谢!!
OK I have an HTTPService
that executes the dataLoaded(e:ResultEvent):void
function whenever it gets a result from a send() call.
OK so If I call HTTPService.send()
and then call HTTPService.send()
again before the previous one receives a result, I end up repeatedly running dataLoaded()
which is undesirable
What I want is if HTTPService.send()
gets called before a previous call to it returns a result. I want to cancel the first call, and only process the result from the last call to HTTPService.send()
I hope this makes sense.
How can I do that??
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
HTTPService 有一个取消方法。如果您在没有参数的情况下调用它,它应该取消该服务的最后一次调用。尝试一下,看看您是否仍然收到不需要的 ResultEvents。
使用 ASyncToken 的存在来确定取消是否合适。
HTTPService has a cancel method. If you call it without its parameter, it should cancel the last invocation of the service. Give that a try and see if you're still getting undesired ResultEvents.
Use the existence of the ASyncToken to determine whether cancellation is appropriate.
实际上 HTTPService 可以为你管理这个。它有一个并发属性,您可能应该将其设置为“last”。
更多信息请参见:HTTPService#并发
Actually HTTPService can manage this for you. It has a concurrency property, which you should probably set to "last".
More info here: HTTPService#concurrency
除了罗伯特的回答之外: Flex:取消 HTTPService.send()?
HTTPService #concurrency 似乎是在 Flex 4 之前引入的,我在 Flex 3 中没有找到这个。。在 Flex 3 中,您必须手动取消先前的调用,这与 Flex 4 中的 concurrency="last" 不同。
请注意,这不会中断先前调用调用的服务器进程,这意味着服务器可能仍会退出然而Flex已经放弃了这一回应。
In addition to Robert's answer: Flex: Cancel HTTPService.send()?
HTTPService#concurrency seems to be introduced until Flex 4, I don't find this in Flex 3.. In Flex 3., you have to cancel the previous call manually in contrast to concurrency="last" in Flex 4.
Note that this won't interrupt server process that previous call invokes, it means server may still come out a response however flex abandon that already.