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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:20:18+00:00 2026-05-27T01:20:18+00:00

I am wanting to progmatically create a new threads that programatically creates a browser

  • 0

I am wanting to progmatically create a new threads that programatically creates a browser tab and performs events within that browser tab. The problem is that I get a message saying I cannot perform UI affects on UI objects in the parent thread.

So I need to find a way to tell the new thread to use the UI objects of the primary thread. This should be easy to do right?

Here is the snippet of code so far that I’m working with:

//....to this point we have told the code to run selected items in a datagrid. Each will have it's own thread.


            if (row.Cells[1].Value.ToString() == "True")
            {
                count_active++;
                //begin multithreading
                Thread this_thread = new Thread(() => f_play_campaign(row.Cells[0].Value.ToString(), row.Cells[2].Value.ToString()));
                this_thread.Name = "thread_" + row.Cells[0].Value.ToString();
                this_thread.IsBackGround = true;
                this_thread.Start();

            }

        }

        if (count_active == 0)
        {
            MessageBox.Show("No campaigns are selected!");
        }
    }


    private void f_play_campaign(string project_id, string tab_name)
    {
        //MessageBox.Show(tab_name);
        //add new tab
        string browsername = f_create_new_tab(tab_name); //this is where the code breaks!
        Control browser = f_get_control_by_name(browsername);

        //MessageBox.Show(browser.ToString());

        //... do more code

Is there an easy way to tell the thread to use the UI objects of the primary thread? I could not figure out how to use Invoke() when I’m trying to get a return value from my method f_create_new_tab(), and I’m so new at this that I’ve not figured out how to use a background worker in the same fashion as threads.

I’ll continue reading other threads on this issue but hopefully someone knows a extremely easy an elegant solution that would satisfy a php programmer like me.

  • 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-27T01:20:19+00:00Added an answer on May 27, 2026 at 1:20 am

    I had to deal with this issue a few days earlier. It’s fairly easy to solve:

    Thread this_thread = new Thread(() =>
        this.Invoke((MethodInvoker)delegate
        {
            f_play_campaign(row.Cells[0].Value.ToString(), row.Cells[2].Value.ToString();
        }));
    

    Basically you need to pass into Invoke a MethodInvoker delegate, which is defined as public delegate void MethodInvoker().

    If you wanted to use BackgroundWorker it’s very similar:

     BackgroundWorker worker = new BackgroundWorker();
     worker.DoWork += (s, e) =>
     {
         this.Invoke((MethodInvoker) delegate { MyJobHere(); });
     };
    
     // Do the work
     worker.RunWorkerAsync();
    

    If you want to return some value, you could do something like this:

    BackgroundWorker worker = new BackgroundWorker();
    int value;
    worker.DoWork += (s, e) =>
    {
        this.Invoke((MethodInvoker) delegate { value = DoSomething(); });
    };
    
    worker.RunWorkerAsync();
    
    
    // do other processing
    while (worker.IsBusy)
    {
        // Some other task
    }
    
    // Use the value
    foo(value);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wanting to create an application in winforms that calls a new WCF
I'm wanting to create an android app that gathers information and then uploads to
I am wanting to create an application that will monitor the upload/download traffic of
I'm wanting to get the full value of a char[] variable in the VC6
This is probably a noob question that I will get slated for but here
Wanting to create custom data annotation validation. Are there any useful guides / samples
I am wanting to have an In-App Purchase that allows my users to import
In wanting to get some hands-on experience of good OO design I've decided to
Im wanting to create an editor for a List of Models which exists as
I'm wanting to be able to create a banner of floating images based on

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.