views:

123

answers:

2

I want to use the <operation>Asnyc methods rather than the Begin<operation>/End<operation> on my WCF service client proxy because I'm updating WPF controls and need to make sure they're being updated from the UI thread. I could use the Dispatcher class to queue items for the UI thread but that's not what I'm asking about..

I've configured the service reference to generate the asynchronous operations, but it only generates the methods in proxy's implementation, not it's interface. The interface only contains synchronous and Begin<operation>/End<operation> methods.

Why aren't these methods generated in the interface and is there a way to do this, or do I have to create a derived interface to manually add them?

A: 

I ended up creating my own interface manually like this:

public interface IMyServiceProxy : IGeneratedServiceProxy
{
   void GetEntityAsync(GetEntityRequest request);
   void GetEntityAsync(GetEntityRequest request, object userState);
   event EventHandler<GetEntityCompletedEventArgs> GetEntityCompleted;
}

and then creating a derived class which implements my interface:

public class MyServiceProxy : GeneratedServiceProxy, IMyServiceProxy
{
}

Let me know if anyone finds a better workaround.

Charlie
A: 

Your project needs to target .NET Framework 3.5 in order to generate event-based proxies. See "How to enable" section here.

BBb