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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:35:04+00:00 2026-05-23T08:35:04+00:00

I have a Silverlight application that uses WCF services and also uses the Wintellect

  • 0

I have a Silverlight application that uses WCF services and also uses the Wintellect Power Threading library to ensure logic executes fully before the application continues. This is achieved by calling back to the application using delegates so it can continue after the service call has completely finished.

I wish to achieve the same thing in another part of my application but without the use of callbacks e.g. call method that uses WCF service to say load an object from the database, wait for this to return and then return the Id of the object from the original method called.

The only way I could see to do this was to carry out the call to the WCF service in a helper library which loads the object on a different thread and the original method would keep checking the helper library (using static variables) to wait for it to complete and then return it.

Is this the best way to achieve this functionality? If so here are details of my implementation which is not working correctly.

public class MyHelper
{

    private static Thread _thread;
    private static User _loadedObject;        

    public static GetUser()
    {
        return _loadedObject;
    }

    public static void LoadObject(int userId)
    {
        _loadedObject = null;
        ParameterizedThreadStart ts = new ParameterizedThreadStart(DoWork);           
        _thread = new Thread(ts);
        _thread.Start(userId);

    }

    private static void DoWork(object parameter)
    {            
        var ae = new AsyncEnumerator();
        ae.BeginExecute(DoWorkWorker(ae, Convert.ToInt32(parameter)), ae.EndExecute);    
    }

    private static IEnumerator<Int32> DoWorkWorker(AsyncEnumerator ae, int userId)
    {
        // Create a service using a helper method
        var service = ServiceHelper.GetService<IUserServiceAsync>();
        service.BeginGetUserById(userId, ae.End(), null);
        yield return 1;

        _loadedObject = service.EndGetUserById(ae.DequeueAsyncResult());
        _thread.Abort();
    }
}

My method then is:

public int GetUser(int userId)
{
    MyHelper.LoadObject(userId);
    User user = MyHelper.GetUser();
    while (user == null)
    {
        Thread.Sleep(1000);
        user = MyHelper.GetUser();
    }
    return user.Id;
 }

The call to the get the user is executed on a different thread in the helper method but never returns. Perhaps this is due to the yield and the calling method sleeping. I have checked the call to get the user is on a different thread so I think everything should be kept separate,

  • 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-23T08:35:04+00:00Added an answer on May 23, 2026 at 8:35 am

    The whole construct you are using does not match current best practices of Silverlight. In Silverlight your data access methods (via WebServices of course) are executed asynchronously. You should not design around that, but adapt your design accordingly.

    However calling services sequentially (which is different than synchonously) can be valid in some scenarios. In this blog post I have shown how to achieve this by subscribing the Completed event of the remote call and block the UI in the meantime, with which the workflow looks and feels like normal async calls.

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

Sidebar

Related Questions

I have a Silverlight application that communications with an ASP.NET backend through WCF. I
I have a Silverlight 2 application that is consuming a WCF service. As such,
I have a silverlight 2 beta 2 application that accesses a WCF web service.
I have a Silverlight application that is built from a set of Silverlight class
I have a Silverlight application which has on it a Canvas. On that Canvas,
I have written a WPF application that I want to port to Silverlight 2.
I have an MVC application that among other things contains a small Silverlight menu
I have a control in Silverlight 2 that changes state during the application. When
I have a Silverlight application in which I would like to call a WCF
I'm a .Net developer and want to get into developing Silverlight applications. I have

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.