是否可以中止 Flex RemoteObject 调用?我尝试了以下方法,但 http 请求仍在后台加载:
var r:RemoteObject = new RemoteObject('<myDestination>');
r.source('myClass');
r.myMethod.addEventListener(ResultEvent.RESULT, myResponse);
r.myMethod(); // lets say this method takes 5 second to call
r.channelSet.disconnectAll(); // I thought this would abort the actual HTTP request but its still running
编辑
我感兴趣的是释放浏览器的 HTTP 管道,就像在 javascript 中一样,您可以在 XHR 上使用 abort。
最佳答案
您可以尝试AbstractOperation的cancel()
方法.
r.getOperation("OperationName").cancel();
更新:
This is the problem, I invoke a large call then the user leaves the view so I don't need to wait for the response anymore. Right now the http request is blocking any further requests. Got any solution for this?
您应该在服务器端服务中进行另一个操作来停止当前服务。然后,当您需要中止当前正在运行的服务时,取消该操作(在flex上),然后通过从flex端调用stop服务来调用停止服务。
停止服务器端当前正在运行的线程,取决于您使用的服务器端。
关于apache-flex - 中止 RemoteObject 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5578406/