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 8617967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:59:51+00:00 2026-06-12T05:59:51+00:00

wonder if anyone can tell me where i’m going wrong. i’ve added a service

  • 0

wonder if anyone can tell me where i’m going wrong.
i’ve added a service reference in my wpf application VS2012

however my wait on the Async call is blocking, i’m not doing anything with it at the moment.
The Async call I got for free when I added the Service reference…

Yet when I await ma.searchModelsAsync I’m blocked…

can anyone shed some light on this??

first I call the function like this:

private async void Button_Click_1(object sender, RoutedEventArgs e)
{
    button1.IsEnabled = false;

    var cnt = await GetDataFromWcf();
    button1.IsEnabled = true;
}

here is the actual function I call

public async Task<List<ViewModels.ModelInfo>> GetDataFromWcf()
{
    using (var ma = new DataGenic.ModelActionsServiceTypeClient())
    {
        var modelInfos = await ma.searchModelsAsync(new ModelSearchCriteria { Category = "ECB" }, 1, 50);
        return modelInfos.Select(mi => new ViewModels.ModelInfo { Id = mi.Id, Name = mi.Name, Uri = mi.Uri }).ToList();
    }
}

btw: if I put the function in a Task.Run(() => ... then it behaves as I expcect…

Not sure if WCF is really giving me what I want.. ideas anyone?

  • 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-12T05:59:53+00:00Added an answer on June 12, 2026 at 5:59 am

    Based on the comment thread thus far, it sounds like there’s enough work happening before the WCF task starts up such that you’d like to have GetDataFromWcf return to the caller sooner than that. That’s a somewhat common issue with async methods (IMHO) – the ‘gotcha’ that they run synchronously up until that first ‘await’ call, so they can still cause noticeable UI delays if too much is happening before the first ‘await’ 🙂

    Because of that, a simple change would be to use Task.Yield (by adding await Task.Yield(); as the first line in GetDataFromWcf) which changes the behavior to have the async method return back to the caller immediately. As the MSDN doc mentions, you can use await Task.Yield(); in an asynchronous method to force the method to complete asynchronously. That sentence alone (and how silly it sounds on the surface) helps show the ‘gotcha’ IMHO 🙂

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

Sidebar

Related Questions

I wonder if anyone can help me to understand where I could be going
I wonder is anyone can look at this code and tell me why calling
I wonder what the >>= operator in C# does. Can anyone tell me?
I wonder if anyone can advise. I have written a .NET 4 WCF service
I wonder if anyone can tell me why does QueryStatus() method get called so
I wonder if anyone can point me in the right direction I'm fairly new
I wonder if anyone can help improve my understanding of JOINs in SQL. [If
I wonder if anyone can think of a good technique to enable any arbitrary
I wonder if anyone can help - I have this error showing recently when
I have a bit of a pickle here and wonder if anyone can give

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.