WCF Asynchrous call in C#

Posted on 2011-10-19
Last Modified: 2012-05-12
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.
Question by:Easwaran Paramasivam
    LVL 39

    Expert Comment

    by:Kyle Abrahams
    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.
    LVL 16

    Author Comment

    by:Easwaran Paramasivam
    Thanks for your comments. But I would like to get answer for the questiong I mentioned above. Could you please give more points?
    LVL 39

    Accepted Solution

    LVL 16

    Author Closing Comment

    by:Easwaran Paramasivam

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Article by: Ivo
    C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
    In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now