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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:24:55+00:00 2026-06-06T23:24:55+00:00

i am using a backgroundWorker to do a long running operation: BackgroundWorker backgroundWorker =

  • 0

i am using a backgroundWorker to do a long running operation:

BackgroundWorker backgroundWorker = new BackgroundWorker() { WorkerSupportsCancellation = true, WorkerReportsProgress = true };

backgroundWorker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
{

};

backgroundWorker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args)
{
    someViewModel.SomeProperty.Add((SomeObject)args.UserState);
};

backgroundWorker.DoWork += delegate(object s, DoWorkEventArgs args)
{
    someViewModel.SomeList.ForEach(x =>
    {
        someViewModel.SomeInterface.SomeMethod(backgroundWorker, someViewModel, someViewModel.SomeList, x);
    });
};

backgroundWorker.RunWorkerAsync();

Then in SomeInterface.SomeMethod:

public void SomeMethod(BackgroundWorker backgroundWorker, SomeViewModel someViewModel//....)
{
    //Filtering happens

    backgroundWorker.ReportProgress(0, someObjectFoundWhileFiltering);
}

So, when it comes to:

backgroundWorker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args)
{
    someViewModel.SomeProperty.Add((SomeObject)args.UserState);//Adding the found object to the Property in the VM
};

On the line someViewModel.SomeProperty.Add((SomeObject)args.UserState);, the set on the SomeProperty is not firering and the UI just locks up.

What am i doing wrong? Is this the correct way to update the UI thread?

  • 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-06T23:24:57+00:00Added an answer on June 6, 2026 at 11:24 pm

    Found a work around for now:

    DeepClone the object.

    backgroundWorker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
    {
        ViewModel.SomeList = DeepClone<List<SomeObject>>(ViewModel.TempList);
    };
    
    backgroundWorker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args)
    {
        var item = DeepClone<SomeObject>((SomeObject)args.UserState);
    
        ViewModel.TempList.Add(item);
    };
    
    public static T DeepClone<T>(T obj)
    {
        using (var ms = new MemoryStream())
        {
            var formatter = new BinaryFormatter();
            formatter.Serialize(ms, obj);
            ms.Position = 0;
    
            return (T)formatter.Deserialize(ms);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a longer running multi-step process using BackgroundWorker and C#. I need to
What is the difference between: Starting a new thread Using TPL Using BackgroundWorker All
I have a WPF application, where I make a long-running WCF call using the
WPF - I'm using BackgroundWorker to create a Model3D object, but when I want
I want to start a job in a new thread or using backgroundworker to
A winforms dialog is using BackgroundWorker to perform some asynchronous operations with significant success.
I'm using a backgroundworker to run a separate thread, however it seems that my
Say I'm showing the user a form, and using a BackgroundWorker to do some
I have two questions about using a BackgroundWorker: 1)Lets say you have Function A
EDIT - After playing around with a bunch of potential solutions (using backgroundworker and

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.