Difference between WCF synchronization and asynchronous call?

I am new to WCF, I want to know what difference does a synchronization call or an asynchronous call make, it will be really useful if someone explains with an example

Thanx

+4
source share
2 answers

The asynchronous call from the client is the same as any asynchronous ohter operation in the .NET Framework. When you make a synchronization call from a thread to a WCF service, the thread will hang. This means that the thread cannot do any other work until the service call returns a response or exception. In contrast, an asynchronous call will be launched in a separate thread (created by the framework), so your main thread will be able to continue working, and it will be notified of the completion of the asynchronous call by a callback (event).

Suppose you have a WinForms application as a WCF client and you want to call the WCF service. If you make a synchronization call that takes a few seconds to complete your application, it will hang for this processing time = the user will not be able to do anything with the application (just kill him from the task manager). But if you use an asynchronous call, it will be fully interactive, since the async operation will be handled by the background thread. Thus, asynchronous operations are suitable for interactive solutions or if you need to perform several operations in parallel.

For example, check out an article article from MSDN.

Just for completeness, I described the difference between synchronization and asynchronous calls = synchronous and asynchronous processing on the client. WCF also supports synchronous and asynchronous operations = synchronous and asynchronous processing on the server.

+6
source

WCF supports asynchronous support. There are various scenarios for using asynchronous calls.

If your application needs to make a WCF call, which, in turn, will require a lot of time, it is better to make an asynchronous call. This will immediately give the user control so that the application does not look hung. Once the WCF background call completes, it will let the application user know that this is done.

Say you have a WCF that inserts some rows into a table. Suppose WCF asks for the name of the tab and the lines to be inserted as arguments. Therefore, if you need to call WCF 3 times to insert rows into 3 separate tables, it might be better to run 3 asynchronous calls that can work in parallel rather than inserting rows into 3 tables sequentially one after another.

Get a good read: http://www.codeproject.com/KB/WCF/WCFConcurrency.aspx

+3
source

All Articles