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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:45:57+00:00 2026-06-13T18:45:57+00:00

Need to make an addition to a program that is currently in production and

  • 0

Need to make an addition to a program that is currently in production and I can’t really do much architecture changes.

Main Thread (T1) -> GUI Elements
Other Threads (T2…) -> Calculation Elements (and outside events).

There is an object class Foo that is running on T2.
Foos are created based on various outside events.

I need to add a DataGrid to a new form that will simply display the properties of different Foo objects.

Foo implements INotifyPropertyChanged

winform GridForm has a BindingList<Foo> FooList object. GridView’s data is bound to it.

Obviously I am making a x-thread call when I call NotifyPropertyChanged in my Foo
and that doesnt work.

I cannot spawn my Foo objects from the main thread, nor i can make the form on Thread2.

Im scratching my head here on how to invoke the main thread.

I do have a static class Foo-Brain that has a reference to the main form (and thus I can get the GUI thread.). The question is how to tie this all together.

Any ideas?

(I was thinking about duplicating Foo objects and running them on the GUI thread and have the FooList containt those, but that seems way to hacky and inefficient).

Thanks.

PS. Hope everyone is alright with Sandy.

EDIT: Sample Code:

class Person : INotifyPropertyChanged // this is the object that will be updated from a
     //different thread; It will have the reference to the main form (GUI)
{
    public event PropertyChangedEventHandler PropertyChanged;
    string comments;  
    private Form1 mainForm = null;

    private void NotifyPropertyChanged(string name)
    {
        if (PropertyChanged == null) return;
        PropertyChanged(this, new PropertyChangedEventArgs(name));         
    }


    public Person(string comments, Form1 f) 
    {
        this.mainForm = f;
        this.comments = comments;
    }

    public string Comments 
    {
        get { return comments; }
        set
        {   comments = value;
            NotifyPropertyChanged("Comments");
        }
    }
}

The code from GUI form:

private void Form1_Load(object sender, EventArgs e)
{
    gridControl.DataSource = gridDataList;
}

private void runmethread()
{
    Thread t = new Thread(anotherthread);
    t.Start();
}

private void anotherthread()
{
    gridDataList[0].Comments = "NEW THREAD";
}

private void button1_Click(object sender, EventArgs e)
{
    runmethread();
}

private void button2_Click(object sender, EventArgs e)
{
    gridDataList[0].Comments = "OLD THREAD";
}

obviously button1_click with cause the x-thread problem (what I am trying to solve)

  • 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-13T18:45:59+00:00Added an answer on June 13, 2026 at 6:45 pm

    I think this is what you are asking …

    Change your INotifyPropertyChanged implementation in Foo to:

    public class Foo: INotifyPropertyChanged
    {
    
      public event PropertyChangedEventHandler PropertyChanged;
    
      private void NotifyPropertyChanged(String propertyName = "")
      {
          if (PropertyChanged != null)
          {
           if (mainForm.InvokeRequired)
           {
               mainForm.Invoke((MethodInvoker) delegate
               {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
               });
            }
            else
            {
               PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); 
            }
          }
      } 
    }
    

    This will make sure that whenever a PropertyChanged event occurs (and for its entire duration while its running), it will be the only thing that T1 will run.
    So the PropertyChanged can be raised from both threads no problem.

    related article you may find educational or confusing:) there is no middle ground:)

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

Sidebar

Related Questions

I need to make sure that every users accessing my web application can do
I need make some action (dump statistical data) before the Dart program ends. The
Need to make certain Ruby strings in my program to be immutable. What is
I need to make a administrative GUI with lots of functionality like lists, forms,
I need to make the top header of a report disappear. The part that
hello im new and learning javascript. I'm trying to make a program of addition
Is there any way that i can make my project (with multiple forms using
I created a program in C that uses OpenCV. In addition to distributing the
As an addition to my current application, I need to create a separate thread
I need make all of my posts update. I use bulk upload for store,

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.