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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:48:04+00:00 2026-06-03T02:48:04+00:00

I have an async method in a WCF service, and a client that consume

  • 0

I have an async method in a WCF service, and a client that consume this method. When I call the method, the GUI of the client is blocked until the async method finish. My code is the following:

SERVICE

public IAsyncResult BeginAsyncMethod(CustomClass paramCustomClass, AsyncCallback callback, object state)
        {            
            Task<bool> task = Task<bool>.Factory.StartNew(p => slowMethod(paramCustomClass, state);
            return task.ContinueWith(res => callback(task));
        }


public bool EndAsyncMethod(IAsyncResult paramResult)
        {
            return ((Task<bool>)paramResult).Result;
        }

slowMethod is a dummy method with a for from i = 0 to 1000000000.

CLIENT

private void callAsyncMethod()
{
      Task<bool> task = Task<bool>.Factory.FromAsync(_proxy.Proxy.BeginAsyncMethod, _proxy.Proxy.EndAsyncMethod, CustomClass, null);    
      bool hasFinished= task.Result;
}

In the client, I have a button that calls the callAsyncMethod, and when I click the button, the GUI gets bloked while the slowMethod is running.

If I am not wrong, the async methods return the control to the caller to avoid the program was blocked, but in my case this does not occur. have I misunderstood something? I am using in the wrong way the async methods?

Thanks.
Daimroc.

  • 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-03T02:48:05+00:00Added an answer on June 3, 2026 at 2:48 am

    Even though the methods are asynchronous, you’re waiting for the result to return, effectively blocking the calling thread (UI). When you access the Result property of the Task object, if the task hasn’t been completed, it will block until the result is available.

    You should call the asynchronous method asynchronously. If you’re using .NET 4.5, you can use the await keyword:

    private async void callAsyncMethod() 
    { 
        Task<bool> task = Task<bool>.Factory.FromAsync(_proxy.Proxy.BeginAsyncMethod, _proxy.Proxy.EndAsyncMethod, CustomClass, null);     
        bool hasFinished = await task;
    }
    

    Otherwise you’ll really need to make the call asynchronous

    private void callAsyncMethod() {
        _proxy.Proxy.BeginAsyncMethod(CustomClass, null, MyCallback, _proxy);
    }
    
    private void MyCallback(IAsyncResult asyncResult) {
        bool hasFinished = _proxy.Proxy.EndAsyncMethod(asyncResult);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that looks something like this in javascript: forloop { //async call,
I have a WCF service that I want to use the async pattern on
In my WCF service contract I have declared an asyn method that return a
Assume that I have Silverlight app doing a call to a WCF service: void
I have web application with WCF service. That service contains method that implements message
I have a piece of code (on a server) that uses async method to
I have this sample code for async operations (copied from the interwebs) public class
I have a Perl code that use threads and HTTP::Async with multiple outbound IP
I have a WCF service that provides a couple of methods. A Windows Forms
I have a Silverlight 3 application which needs to call WCF service. The WCF

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.