简体   繁体   English

WCF(SOAP):异步服务操作

[英]WCF (SOAP): async Service Operations

When consuming WCF SOAP Services, the visual studio automatically creates both synchronous and asynchronous versions of the methods in the server, in the client consumer application. 在使用WCF SOAP服务时,visual studio会在客户端使用者应用程序中自动在服务器中创建方法的同步和异步版本。 For example this non-async method in the server: 例如,服务器中的这种非异步方法:

public Data GetData(){
 return data;
} 

can be used both as 既可以用作

var i = client.GetData();

or 要么

var i = await client.GetDataAsync();

Now my question is that, would it be beneficial to make use of async service operation methods on the server side at all? 现在我的问题是,在服务器端使用异步服务操作方法是否有益? I mean if implementing the service contract methods as async, will there be any performance enhancement in the server side at all or not? 我的意思是如果将服务合同方法实现为异步,那么服务器端是否会有任何性能提升?

...if implementing the service contract methods as async, will there be any performance enhancement in the server side at all or not? ...如果将服务合同方法实现为异步,那么服务器端是否会有任何性能提升?

No there will not be any difference at all on the server side. 不,服务器端根本没有任何区别。 The async service operations on the client are a purely client-side implementation. 客户端上的异步服务操作是纯粹的客户端实现。 The incoming calls will be indistinguishable by the service. 来电将无法通过服务区分。

do you think implementation of IDisposable for the service would be beneficial or not 您是否认为实施该服务的IDisposable是有益的

If you're talking about the service-side code then you'll either be using the ServiceHost container to run your service, which already implements IDisposable, or it will be loaded dynamically from IIS or WAS, in which case you don't have control at the correct grain to implement IDisposable. 如果您正在讨论服务端代码,那么您将使用ServiceHost容器来运行已实现IDisposable的服务,或者它将从IIS或WAS动态加载,在这种情况下您没有控制正确的谷物以实现IDisposable。

If your service's internal code uses any unmanaged resources in the course of execution then you'll need to manage the disposal of those things, but this is a .net 101 and holds true for anything not just WCF. 如果您的服务的内部代码在执行过程中使用任何非托管资源,那么您将需要管理这些内容的处理,但这是一个.net 101并且适用于任何不仅仅是WCF的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM