Flex中的同步和异步调用
Flex中的同步调用和异步调用是什么?为什么Httpservice是异步的以及如何进行异步调用。
谢谢, 拉维
what is synchronous and asynchronous call in flex. Why Httpservice is asynchronous and how to make a call to asynchronous call.
Thanks,
Ravi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 FlashPlayer 中,所有远程调用都是异步的。 Adobe Virtual Machine 2 不支持多线程同步执行任何调用。远程调用为您提供一个对象(例如 AsyncToken),它将在结果或错误时调度事件。
All remote calls are asynchronous in FlashPlayer. Adobe Virtual Machine 2 doesn't support multi-threading to do any call synchronously. Remote call gives you an object (for example AsyncToken) that will dispatch event on result or fault.
对于同步调用,UI 将被阻塞,直到收到响应。由于没有向开发人员公开线程 API,并且阻塞 UI 对用户来说根本不友好,因此对外部源的调用是异步的。这允许 UI 在调用执行时继续运行。当收到结果或错误时将调度事件。
此规则有一个例外:在 AIR 中,可以打开与本地 SQLite 数据库的异步或同步连接。
With synchronous calls, the UI will be blocked until a response is received. Since there is not threading API exposed to the developer and blocking the UI is not user friendly at all, calls to external sources are asynchronous. This allows the UI to continue running while the call is executing. Events will be dispatched when a result or fault is received.
There is one exception to this rule: in AIR, it is possible to open asynchronous or synchronous connections to a local SQLite database.
网络调用为什么是异步的?我同意从 SWF 角度来看,对网络的调用将是异步的,但与 HttpService/Webservice 通信的实际网络库将始终是同步的。尽管他们会在收到回复后立即发送。
因此,除非您实现消息传递服务,否则网络调用将是同步的。
但从 SWF 角度来看,由于它不支持多线程请求,它会在网络库触发完成事件/故障时处理响应
How come a network call be asynchronous? I agree from SWF prespective a call to network will be asynchronous but actual network libraries communicating with HttpService/Webservice will always be synchronous. Although they will be dispatching an even once response is received.
So a network call will be syncronous, unless you implement Messaging Service.
But from SWF view since it doesnt support multithreaded request, It handles the response when event/fault of completion is triggered by network libraries