Flex:取消 HTTPService.send()?

发布于 2024-08-19 16:05:37 字数 428 浏览 7 评论 0原文

好的,我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

思念满溢 2024-08-26 16:05:37

HTTPService 有一个取消方法。如果您在没有参数的情况下调用它,它应该取消该服务的最后一次调用。尝试一下,看看您是否仍然收到不需要的 ResultEvents。

使用 ASyncToken 的存在来确定取消是否合适。

private var _serviceCall:ASyncToken;

function callMyService(stuff:Object):void {
    if (_serviceCall !== null) {
        myService.cancel();
        _serviceCall = null;
    }
    _serviceCall = myService.send(stuff)
}

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.

private var _serviceCall:ASyncToken;

function callMyService(stuff:Object):void {
    if (_serviceCall !== null) {
        myService.cancel();
        _serviceCall = null;
    }
    _serviceCall = myService.send(stuff)
}
子栖 2024-08-26 16:05:37

实际上 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

回梦 2024-08-26 16:05:37

除了罗伯特的回答之外: 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文