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

  • Home
  • SEARCH
  • 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 1093555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:50:36+00:00 2026-05-16T23:50:36+00:00

in WPF application I load a list of business objects by WCF to a

  • 0

in WPF application I load a list of business objects by WCF to a listbox.
I want to load it in another thread and display a progressbar window.

But how? I need to call WCF service in the second thread and return its return value to the first (UI) thread. And this is the point I don’t know. How to return?
Or what should be the correct workflow of calling for data at background and displaying of progress?

Now I:
– show the progress window
– create a new thread and call the WCF service
– return values <– I don’t know
– close window

But – is this workflow right?

I don’t want to use a backgroundworker because I can call many different WCF services, not only one I could write into the DoWork method.

I have a WCFClient class in which I call all services I need. Here is a one of the methods (all methods are same only calls different services):

public class Client
{
    public List<BusinessDto> GetBusinesses(int userID)
    {
        OnConnecting();

        ServiceClient client = null;
        BusinessDto[] dtos = null;
        try
        {
            client = new ServiceClient();
            dtos = client.GetBusinesses(userID);
        }
        catch
        {
            MessageBox.Show(Properties.Resources.ConnectionNotSucessful, Properties.Resources.ApplicationName, MessageBoxButton.OK, MessageBoxImage.Error);
        }
        finally
        {
            if (client != null) client.Close();

            OnClosing();

        }
        return dtos.ToList();
    }
}

I’m catching an Onconnecting and OnClosing events of WCFClient and opening and closing a new window with progressbar.

But I do not call WCF services in a new thread, because I don’t know how.

Thanks, I’m trying do that unsuccessfuly for a two days.

  • 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-16T23:50:36+00:00Added an answer on May 16, 2026 at 11:50 pm

    I don’t want to use a backgroundworker because I can call many different WCF services, not only one I could write into the DoWork method.

    Well, first, you can decide which of many DoWork methods you want to call at the time you prepare the BackgroundWorker. But you can also (and this is probably more maintainable) write a DoWork method of arbitrary complexity. You can write a DoWork method that takes an argument of type Client, and have it call a member method on that object, for instance. There’s absolutely nothing limiting about this method.

    The way I’d implement a progress bar window:

    1. Implement a Task class that exposes three methods: SetUp, Execute, and TearDown, as well as a Status property, which is a struct containing int PercentComplete and string Message. Implement INotifyPropertyChanged.
    2. Implement a protected UpdateStatus method that updates Status and raises PropertyChanged.
    3. Build a modal window that implements a ShowDialog(Task t) method. In that method, call t.SetUp(), then create a BackgroundWorker.
    4. Handle t.PropertyChanged and have the handler raise the BackgroundWorker‘s ProgressChanged event.
    5. Have the BackgroundWorker‘s ProgressChanged event handler use t.Status to update the UI,
    6. Have the BackgroundWorker‘s DoWork event handler call t.Execute().
    7. Have its its RunWorkerCompleted event handler both handle exceptions (do not neglect this!) and call t.TearDown().
    8. Build and test Task subclasses as needed.
    9. Whenever you need to display a progress bar window, instantiate the appropriate Task, set whatever properties it needs, and then call ProgressBarWindow.ShowDialog(t). This will display the window and block and wait while the background process runs, updating the UI as it goes; it will return after t.TearDown() gets called.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want my WPF application to be skinnable, by applying a certain XAML template,
I have written a WPF application that I want to port to Silverlight 2.
In the entry form of my wpf application, I have a list of buttons
I have a simple WPF application which I am trying to start. I am
I have a WPF application in VS 2008 with some web service references. For
I'm benchmarking a WPF application on various platforms and I need an easy way
After developing a WPF application without Source Control, I decided to add the solution
I have a simple WPF application with a menu. I need to add menu
I am creating a WPF Application using VS 2005. I download the add on
I'm making a WPF application that is comprised of Screens (Presenter + View). 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.