Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8594485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:12:39+00:00 2026-06-12T00:12:39+00:00

I have created a WCF service and have its operationcontract and implementation like this:

  • 0

I have created a WCF service and have its operationcontract and implementation like this:

    [OperationContract]
    Task<string> GetName(string name);

   public async Task<string> GetName(string name)
    {
         await Task.Delay(5000);
         var task1 = Task<string>.Factory.StartNew(() =>
         {
             return "Your name is : " + name;
         });
         var result = await task1;
         return result;
        }

Now i am using this service at client side and created the client.

 ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();

It shows be 2 methods for my implementation: GetName and GetNameAsync

I can use the following two ways to access the service.

var result_GetName = await Task.Factory.StartNew(() => client.GetName("My Input"));
 var result_GetNameAsync = await client.GetNameAsync("My Input");
  • Q.1 Is there any difference between the two approaches?
  • Q.2 Is it recommended to use one of them in particular condition? or i can use any of them at any time.
  • Q.3 For the second call i am using async-await at two places (client-server), is there any advantage of it?

Please guide.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:12:41+00:00Added an answer on June 12, 2026 at 12:12 am

    I don’t know what the generated code looks like for WCF, but I’d expect the second form to be better. (EDIT: Read Stephen’s blog post for details of why this is true.)

    The first approach creates a new task which calls the method synchronously – blocking a thread for as long as it takes for the method to return. So if you have lots of those calls concurrently, you’ll end up using a lot of threads and therefore memory.

    I’d expect the second approach to be more “natively” asynchronous – basically sending the request and then handling the response on a potentially different thread when it comes back.

    For your final question:

    For the second call i am using async-await at two places (clien-server), is there any advantage of it?

    You’re using await in two places in both snippets. But yes, there’s definitely an advantage in using asynchronous code in both places. In the client, you’re saving client threads. In the server, you’re saving server threads.

    Using the purely asynchronous version, you could have hundreds of calls from a client to a server, without using more than one or two threads in each of those processes. In the client, you don’t have anything blocked, waiting for the response – you just have continuations ready to be called when the response comes through. In the server, you don’t have anything blocked on a Thread.Sleep call (the logical synchronous equivalent of Task.Delay) – you just have a lot of continuations ready to run when the delay expires.

    So yes, it’s good on each side. You get the benefit wherever you’re using it, basically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note: This might look like duplicate but its not. I have created a .net(WCF)
I have a Data Service created using WCF that internally uses nHibernate. This WCF
I have created a WCF service; its working fine in Visual studio. I have
I have created a WCF service for uploading images , which accepts System.IO.Stream as
We have created a WCF service hosted in a windows service that handles Authentication
I am a WCF / Security Newb. I have created a WCF service which
We have created a WCF RESTful service for a WPF(UI) Application. The UI sends
I have created a web service via WCF. Then I exposed it as a
I have ASP MVC 3 application. I created WCF REST JSON Service and added
I have created one WCF service, in which I am reading the msn whether

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.