Link to home
Start Free TrialLog in
Avatar of Easwaran Paramasivam
Easwaran ParamasivamFlag for India

asked on

WCF Asynchrous call in C#

Hi Experts,

 What is differerenece between calling WCF service synchronously and calling with AsyncWaitHandle.WaitOne() method?

Whether AsyncWaitHandle.WaitOne()  boost the performance?

I've WCF service. Is it good to call the service with AsyncWaitHandle.WaitOne() or any other asynchronous method in all layers such as Business object method of the service and Data access method of it?

I tested with time difference in millisecond before calling the service and after calling the servie but it shows different result in each time. I could not come to conlusion.

Please guide me.
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Synchronous - Code will wait for response to come back - your UI will freeze until the response is processed

Asynchronous - Call is made and awaits an answer on the call back function.  Other operations can be performed and UI will not freeze.


The reason you're not observing a noticeable difference (and getting different results) is that it's very dependant on what is going on within the computer itself (assuming everything is local) or on the network / server (if you're actually talking to servers).  

Add a time delay to your service (EG: thread.Sleep(7000) ) to notice the difference in the calls and simulate a larger list / latency.
Avatar of Easwaran Paramasivam

ASKER

Thanks for your comments. But I would like to get answer for the questiong I mentioned above. Could you please give more points?
ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks.