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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:05:39+00:00 2026-06-09T19:05:39+00:00

if I call form.show() on a WinForms object from another thread, the form will

  • 0

if I call form.show() on a WinForms object from another thread, the form will throw an exception. Is where any way I can add a new, visible form to the main app thread? Otherwise, how can I open the form without stopping my currently executing thread?

Here is my sample code. I am attempting to start a thread and then execute some work within that thread. As the work progresses, I will show the form.

public void Main()
{
    new Thread(new ThreadStart(showForm)).Start();
    // Rest of main thread goes here...
}

public void showForm() 
{
    // Do some work here.
    myForm form = new myForm();
    form.Text = "my text";
    form.Show();
    // Do some more work here
}
  • 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-09T19:05:40+00:00Added an answer on June 9, 2026 at 7:05 pm

    Try using an invoke call:

    public static Form globalForm;
    
    void Main()
    {
        globalForm = new Form();
        globalForm.Show();
        globalForm.Hide();
        // Spawn threads here
    }
    
    void ThreadProc()
    {
        myForm form = new myForm();
        globalForm.Invoke((MethodInvoker)delegate() {
            form.Text = "my text";
            form.Show();
        });
    }
    

    The “invoke” call tells the form “Please execute this code in your thread rather than mine.” You can then make changes to the WinForms UI from within the delegate.

    More documentation about Invoke is here: http://msdn.microsoft.com/en-us/library/zyzhdc6b.aspx

    EDIT: You will need to use a WinForms object that already exists in order to call invoke. I’ve shown here how you can create a global object; otherwise, if you have any other windows objects, those will work as well.

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

Sidebar

Related Questions

How can i make, what i will call, a popup window in WinForms? Since
I'm trying to call a function from a form within the same .php file,
I have a form and from this I call dialogPrintDiet.ShowDialog() which launchs my dialog.
I'm trying to send a getJson call from my app (login form) to get
I create a new form and call from the parent form as follows: loginForm
Is there any way to when you click submit on a form, as each
when i call form.dispose() form always calling Validating event and show MessageBox message. How
I have a very simple Form. When I call Show() on it, it is
I have the following code : This call the second form private void updateToolStripMenuItem_Click(object
I send asynchronous call using jQuery form plugin and in the case of success

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.