Search code examples
c#wcfsvcutil.exeservice-reference

No Begin Async method


I'm new to WCF and Async. I have a service with a Begin and End on a long running method.

[ServiceContract]
public interface IDocImagingStatusService
{
    [OperationContract(AsyncPattern = true)]
    IAsyncResult BeginGetDirectoryCount(AsyncCallback callback, object state);
    IList<DirectoryCounts> EndGetDirectoryCount(IAsyncResult result);
}

My client needs to call BeginGetDirectoryCount but all I see is a GetDirectoryCount() method. Where did they go?

var docImgSvc = new DocImagingService.DocImagingStatusServiceClient( "WSHttpBinding_IDocImagingStatusService");
docImgSvc.GetDirectoryCount();

Solution

  • You probably want to make sure that the proxy was generated with async operations. See http://msdn.microsoft.com/en-us/library/aa347733.aspx if you're using svcutil directly. If you're using Visual Studio's Add Service Reference menu, you'll need to look in the Advanced settings for the option to generate async proxy methods.