It appears I can freely switch between the following three different versions of the same WCF contract interface API, without breaking the clients:
// Either synchronous
// int SomeMethod(int arg);
// Or TAP
Task<int> SomeMethodAsync(int arg);
// Or APM
// [OperationContract(AsyncPattern = true)]
// IAsyncResult BeginSomeMethod(int arg, AsyncCallback callback, object state);
// int EndSomeMethod(IAsyncResult ar);
The existing test client app keeps working without any recompiling or touching. If I do recompile the service and re-import its reference into the client app, the WSDL definition remains the same, 1:1.
- Is it a legit behavior I can rely on? Is it documented anywhere?
The idea is to convert a set of synchronous
SomeMethod-style methods into TAP
SomeMethodAsync-style methods, to use
async/await in their implementation and thus improve the WCF service scalability, without breaking existing clients.
Also, there have been known woes with WCF service scaling under .NET 3.5 and .NET 4.0. They are documented in the MSKB article "WCF service may scale up slowly under load" and the CodeProject article "Tweaking WCF to build highly scalable async REST API". Basically, it wasn't enough to implement the service contract APIs as naturally asynchronous, the WCF runtime still was blocking the request thread.
- Does anyone know if this problem has been fixed for .NET 4.5.x, out-of-the-box? Or the additional tweaks are still required?