Tagged: Services

API tools, security 101, naming sites, javascript libraries


Asynchronous WCF calls without a generated proxy.

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