首页 \ 问答 \ 单向操作与异步调用(One-Way operations vs Asynchronous calls)

单向操作与异步调用(One-Way operations vs Asynchronous calls)

本文第一部分所述 (.chm文件 - 请参阅下面的注释)

单向调用不等同于异步调用。 当单向呼叫到达服务时,它们可能不会立即全部调度,并且可能在服务端排队等待一次调度一次......如果排队消息的数量超过了队列的容量,那么即使发出单向呼叫,客户端也会阻止。

如果调用单向调用,它何时将控制权返回给调用者? 同一篇文章的介绍指出单向调用用于即发即弃操作 ,从而模拟一种异步调用。 如果会话WCF服务具有启动会话的Login()单向方法,此方法何时将控制权返回给调用者? 是否在方法实际执行服务之前返回? 如果是这样,我怎么能确定该方法是在服务上执行的?

如果我希望服务返回到客户端登录过程中可能发生的错误,那么异步调用是实现“即发即弃”行为的唯一方法吗?


注意:上面引用的文章来自一篇名为WCF Essentials的文章- 你需要了解的关于单向调用,回调和事件的内容由Juval Lowy提供,可以在2006年10月的MSDN杂志中找到。 上面的链接是MSDN上的帮助文件(.chm)格式。 如果您无法使链接的CHM文件起作用(我不能),您可以使用7zip打开它。


As stated in the first section of this article (.chm file - see note below)

One-way calls do not equate to asynchronous calls. When one-way calls reach the service, they may not be dispatched all at once and may be queued up on the service side to be dispatched one at a time... If the number of queued messages has exceeded the queue's capacity, then the client will block, even when issuing a one-way call.

If a one-way call is invoked, when does it return control to the caller? The introduction of the same article states that one-way calls are used for fire-and-forget operations, thereby simulating a kind of asynchronous call. If a sessionful WCF service has a Login() one-way method which starts the session, when does this method return control to the caller? Does it return before the method is actually executed on the service? If so, how can I be sure that the method was performed on service?

If I wanted the service to return to the client the possible errors that occur during the login procedure, would be an asynchronous call the only way to achieve a fire-and-forget behaviour?


Note: The quote above is taken from an article called WCF Essentials - What You Need To Know About One-Way Calls, Callbacks, And Events by Juval Lowy, and can be found in the October 2006 issue of MSDN magazine. The link above is to a help file (.chm) format on MSDN. If you can't get the linked CHM file to work (I couldn't) you can open it with 7zip.


原文:https://stackoverflow.com/questions/12112926
更新时间:2022-10-25 10:10

最满意答案

load()事件是危险和模糊的,因为您正在侦听加载事件并同时加载ajax内容。 请试试这个:

  var toInsert = $('video from youtube');

  $(toInsert).on("load", function() {
      $(".composition"+concat(number)).after(toInsert); 
  });

您可以以不同的方式使用延迟:

  $(toInsert).load('url-to-video', function(response, status, xhr ) {
       console.log(response, status, xhr );
  });

这是两种不同的方法。 不要混合两者!

编辑

查看OP的编辑,我看到可能被监听的iframe,而不是DOM元素。

  toInsert.find('iframe').on("load", function() {
      $(".composition".concat(number)).after(toInsert); 
  });

这里你是解释,因为你不必使用load()方法来监听load事件:

http://api.jquery.com/load/

它产生一个AJAX查询。


load() event is dangerous and ambiguous, because you are listening load event and load an ajax content simultaneously. Please, try this:

  var toInsert = $('video from youtube');

  $(toInsert).on("load", function() {
      $(".composition"+concat(number)).after(toInsert); 
  });

You can use a deferred in a different way:

  $(toInsert).load('url-to-video', function(response, status, xhr ) {
       console.log(response, status, xhr );
  });

These are two different ways to do it. Don't mix both!

EDIT

Viewing the edit of OP, I see an iframe that may be listened, and not the DOM element.

  toInsert.find('iframe').on("load", function() {
      $(".composition".concat(number)).after(toInsert); 
  });

Here you are the explanation because you don't must to use load() method to listening load event:

http://api.jquery.com/load/

It makes an AJAX query.

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。