Question

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();
Was it helpful?

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.

OTHER TIPS

By default, the Add Service Reference dialog in Visual Studio and svcutil.exe tool don't generate Async operations for your service contract. In case you want to generate them, you would need to explicitly specify in both options:

  • In Visual Studio 2010, you can select the Advanced button in Add Service Reference dialog and then check the Generate Asynchronous Operations checkbox in Advanced dialog as below:

enter image description here

  • In svcutil.exe tool you would need to use the /async switch as below excerpt in MSDN says:

/async: Generates both synchronous and asynchronous method signatures. Default: generate only synchronous method signatures. Short Form: /a

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top