Dela via


How to: Call a Service Method Asynchronously

Most methods in Windows Communication Foundation (WCF) services may be called either synchronously or asynchronously. Calling a method asynchronously enables your application to continue to work while the method is being called when it operates over a slow connection.

By default, when a service reference is added to a project it is configured to call methods synchronously. You can change the behavior to call methods asynchronously by changing a setting in the Configure Service Reference dialog box.

Note

This option is set on a per-service basis. If one method for a service is called asynchronously, all methods must be called asynchronously.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To call a service method asynchronously

  1. In Solution Explorer, select the service reference.

  2. On the Project menu, click Configure Service Reference.

  3. In the Configure Service Reference dialog box, select the Generate asynchronous operations check box.

See Also

Tasks

Consuming ASMX and WCF Services Sample

Reference

Configure Service Reference Dialog Box

Other Resources

Windows Communication Foundation Services and ADO.NET Data Services