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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:45:38+00:00 2026-05-21T06:45:38+00:00

I now have the following code, which calls a WCF service, it get some

  • 0

I now have the following code, which calls a WCF service, it get some data and then pass the data on to the browser.

The only problem is that client_GetProductCompleted() does not get called until Load() finishes, and by then, it is too late. The browser has already loaded the information.

So basically I am asking, if there is a way of implementing the methods, such that client_GetProductCompleted() gets called as soon as Load() gets called, then it can return the data back to the browser in time 🙂

It is probably silly, but I have tried to ask the program to sleep while waiting for Load() to finish, and it didnt work. So Im totally clueless now …

public static Products _OurProducts = new Products();

public void Load()
{
    ServiceReference1.ServiceClient client = new ServiceReference1.ServiceClient();
    client.getProductsCompleted += 
        new EventHandler<ServiceReference1.getProductsCompletedEventArgs>(
            client_GetProductCompleted);

    client.getProductsAsync();    
    return;
}

void client_GetProductCompleted(object sender, ServiceReference1.getProductsCompletedEventArgs e)
{
    if (e.Result != null)
    {
        ObservableCollection<ServiceReference1.Product> products = e.Result;
        foreach (ServiceReference1.Product prod in products)
        {
            Product temp = new Product(prod);
            _OurProducts.Add(temp);
        }
     }
}
  • 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-05-21T06:45:39+00:00Added an answer on May 21, 2026 at 6:45 am

    It isn’t completely clear, but I suspect you want MethodA to block until the handler finishes executing (presumably on another thread).

    It’s possible that the object you are querying offers a synchronous way of returning its results. This would definitely be the way to go if available.

    If not, you can make the method block until it is signaled, such as with a ManualResetEvent.

    E.g.:

    var resetEvent = new ManualResetEvent(false);
    client.getProductsCompleted += (s, e) => 
                                   { 
                                       client_GetProductCompleted(s, e); 
                                       resetEvent.Set();
                                   };    
    client.getProductsAsync(); 
    resetEvent.WaitOne();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some data fetch service which fetches some entities from main web
I have the following code which turns a string, that I pass into the
I have a .NET windows service which acts as a host for some wcf.
Right now I have the following code working: @UiHandler(usernameTextBox) void onUsernameTextBoxKeyPress(KeyPressEvent event) { keyPress(event);
I have The following code for now. type TByte4 = array[0..3] of Byte; //
I have the following code in my C# program. DateTime dateForButton = DateTime.Now; dateForButton
I have the following code in vb - tAvailableDate = DateAdd(d, 21, Format(Now, gDATEFORMAT))
I have the following code: SPList list = web.Lists[this.ListName]; SPListItem item = list.Items.Add(); now
Say that I have the following code: ExecutorService executor = Executors.newSingleThreadExecutor(); executor.execute(myRunnable); Now, if
Let's say I have the following Code: <div id=parent> <div id=child></div> </div> Now I

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.