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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:53:05+00:00 2026-05-23T11:53:05+00:00

I have a wcf which retrieves information from a database. I also have a

  • 0

I have a wcf which retrieves information from a database.

I also have a Silverlight client application which references that service and uses it to retrieve the data.

public void init(ref Cluster cluster)
{
    _SelectedCluster = cluster;
    MyEntities svc = new MyEntities(new    Uri("http://localhost:49672/MyDataService.svc/"));
        docs = new DataServiceCollection<EC_Documents>();
        var query = from c in svc.EC_Documents
                    where c.clusterID == _SelectedNode.ID
                    orderby c.clusterID
                    select c;

        docs.LoadCompleted += docs_LoadCompleted;      

    docs.LoadAsync(query);
}
    private void docs_LoadCompleted(object sender, LoadCompletedEventArgs e)
    {
        if (e.Error == null)
        {

            if (docs.Continuation != null)
            {
               docs.LoadNextPartialSetAsync();
            }
            else
            {
                _SelectedCluster.Value = docs.Count;

            }
        }
    }

Because the call is asynchronous, I had to make docs a member of the class and check its count at the docs_LoadCompleted method.

I also have a _SelectedCluster which is an object of type Cluster as a member in the class,which holds the current cluster object in the iteration.

I have a problem assigning the result to the currently selected node _SelectedCluster.Value member.

Because the call is asynchronous, I cannot iterate on all my clusters objects and assign the result synchronously, If I do that, the assignment is always on the last cluster in the iteration.

Any suggestions?

  • 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-23T11:53:06+00:00Added an answer on May 23, 2026 at 11:53 am

    Re-arrange your code to benefit from closures:-

    public void init(Cluster cluster)
    {
        MyEntities svc = new MyEntities(new    Uri("http://localhost:49672/MyDataService.svc/"));
            var docs = new DataServiceCollection<EC_Documents>();
            var query = from c in svc.EC_Documents
                        where c.clusterID == _SelectedNode.ID
                        orderby c.clusterID
                        select c;
    
            docs.LoadCompleted += (s, e) =>
            {
                if (e.Error == null)
                {
                    if (docs.Continuation != null)
                    {
                       docs.LoadNextPartialSetAsync();
                    }
                    else
                    {
                        cluster.Value = docs.Count;
                    }
                }
            };      
    
        docs.LoadAsync(query);
    }
    

    Now multiple calls to init can be made each using its own instance DataServiceCollection<EC_Documents>. I’m not sure what you want to do about the _SelectedNode.ID value that looks wrong to me, you ought to be passing that value in as a parameter on the init. Of course with docs now being local you will need to decide what to with it once all the docs for a cluster ID is loaded.

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

Sidebar

Related Questions

I have a WCF service which references a 3rd party DLL. That DLL looks
I have a WCF Web Service which is referenced from a class library. After
I have been having some issues retrieving JSON data from a WCF service application
I have a simple WCF service application which contains a list of room items
I'm have a Silverlight 3 UI that access WCF services which in turn access
I have this WCF application which is hosted as a windows service. This service
I have a WCF service which is hosted in a WinForms application. This WCF
We have a typical multi-tier/layer architecture. Application + WCF Service + Repository/EF4/Database. We are
I have a self-hosted WCF web service running, and an Android client application. I
I have a WCF service that i cannot touch which returns List<FilesWithSettings> . 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.