– Chaining WCF calls – increase threadpool thread count
– Limit of threads in service call – again thread count in threadpool if it’s being used and/or the WCF throttling limits
– Dedicated thread or a Threadpool thread? – use threadpool for async calls
There’s quite a few intriguing problems and answers on stackoverflow; so I think I might start tracking a few on this blog every now and then.
First one presents a solution where multiple threads have a race condition on the manualreset event. I quite like the latch solution since it’s quite straight forward
A decent overview of threading in .NET by Joseph Albahari can be found here
Like many other developers, I like to have control over the code I deploy. To enable asynchronous calls you normally have to generate the proxies with the option for asynchronous calls turned on. In the case where you have your own proxies; the ability to enable asynch calls is pretty simple.
You’ll likely have your standard synchronous interface as follows:
public interface IFileService
FileResults GetFileConfig(FileRequest request);
To provide an asynchronous version simple create another interface; using the name alias against the service contract and asyncpattern set to true. Create a Begin and End pair of functions, post appended with the name of the operation you want to make synchronous.
public interface IAsyncFileService
[OperationContract(AsyncPattern = true)]
IAsyncResult BeginGetFileConfig(FileRequest request, AysncCallback callback, object asyncState);
LoadConfigResults EndGetFileConfig(IAsyncResult result);
Now all your client has to do is is use the new Async interface and the server will resolve to an asynchronous operation.
public class FileServiceProxy : ClientBas<IAsyncFileService>, IAsyncFileService
IAsyncResult BeginGetFileConfig(FileRequest request, AysncCallback callback, object asyncState)
return Channel.BeginGetFileConfig(request, callback, asyncState);
…… // and the End call equivalent