3
votes

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. 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?

1
IINM, in your example use of async to consume an external service will benefit "you", the consumer/client application. - EdSF
@EdSF: Sure but I mean would there be any benefit for using async methods on the server side? - Arnold Zahrneinder
Given the above (no async on server)? Then it won't have any async "benefits"...(unless I'm misunderstanding your question). It will perform "just like it normally does handling requests synchronously" (whether calling client/s is/are requesting via async or not). - EdSF

1 Answers

2
votes

...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

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.

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.