Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement WCF Asynchronous call

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to achieve WCF asynchronous call, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

It turns out that I put a lot of WCF asynchronously calling Demo on the Internet. And I use VS2005, when I use these samples, basically most of the VS2003-based Asp.net projects cannot be loaded because a few files cannot be converted, which bothers me for a long time, and finally let me find a solution.

A good framework design element is that the design and implementation of the service should be consistent regardless of the way the client is invoked (synchronous or asynchronous). For the designer of the service, the way the caller of the service invokes should not be considered at the beginning of the design. In other words, whether the service operation is asynchronous or not should be decided by the caller of the client.

Therefore, everything related to asynchronous invocation should be relevant only to the client. Tag: WCF Asynchronous invocation [quoted from Zhang Yi's blog] WCF differs from Web Service in that when we define the operation of a service contract, whether we create a service proxy object through ChannelFactory or generate a service proxy object by default in SvcUtil, the client cannot directly implement asynchronous invocation when invoking these proxy objects. For example, for the following service operation definition:

[OperationContract] Stream TransferDocument (Document document)

When we call the methods of the proxy object, we cannot find the BeginTransferDocument () and EndTransferDocument () asynchronous methods corresponding to the TransferDocument () operation. This design makes it impossible for us to invoke the operation of the service programmatically asynchronously unless we directly add the asynchronous method of the relevant operation when defining the service interface.

However, this directly leads to the coupling between the design of the service and the way the method is invoked. A good framework design element is that the design and implementation of the service should be consistent regardless of the way the client is invoked (synchronous or asynchronous).

For the designer of the service to invoke the WCF asynchronously, the way the caller of the service invokes should not be considered at the beginning of the design. In other words, whether the service operation is asynchronous or not should be decided by the caller of the client. Therefore, everything related to asynchronous invocation should be relevant only to the client. WCF follows this rule.

In the application I write, a service operation that transfers document files is exposed. I don't know or care whether the client that invokes the operation is asynchronous. Therefore, the service operation definition described above is completely correct.

These are all the contents of the article "how to implement WCF Asynchronous invocation". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report