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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:57:05+00:00 2026-05-15T23:57:05+00:00

I have a windows forms application that runs two threads simultaneously, with the UI

  • 0

I have a windows forms application that runs two threads simultaneously, with the UI thread running in the task bar. The UI thread actually performs completely separate functionality from the other process, but in the case that a new user logs into the application, I need to pop up a setup window from the non-UI thread.

Here is the code from my Program.cs:

static void Main()
    {
        ThreadStart start = new ThreadStart(Waiting.wait);
        Thread waiting = new Thread(start);
        waiting.Start();
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(true);
        Application.Run(TaskBarIcon.getInstance());
    }

Currently, before TaskBarIcon can fully instantiate, one configuration method must be finished running in the waiting thread. This is achieved by passing a lock back and forth.
I would like to have this set up menu pop up while the configuration method is processing, and have the method wait to complete until the setup menu is done running. However, unless I run the set up menu directly from the Application.Run() method, I cannot even get the menu to show up properly.

I’m very new to C#….would be able to do this quickly in Java, but C# seems to do things differently.

Any suggestions or solutions would be greatly appreciated!

badPanda

  • 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-15T23:57:05+00:00Added an answer on May 15, 2026 at 11:57 pm

    I suspect what it is happening is that the setup menu form is not receiving windows messages on the worker thread and that is why it is not showing up. All forms and controls need a message pump to work properly. There are various different ways of getting a message pump started, but the two most applicable to you are:

    • Application.Run
    • Form.ShowDialog

    If you call ShowDialog on the setup menu form then it should show up on the worker thread. Of course the call blocks until the form is closed so that will prevent the remainder of the configuration method from executing, but then again that may be exactly what you want.

    If you want the main UI thread (the one calling Application.Run) to wait until this configuration method is finished then use a WaitHandle to signal when the configuration task is complete. It might look like the following.

    static void Main() 
    { 
      var configured = new ManualResetEvent(false);
      var worker = new Thread(
        () =>
        {
           // Do some stuff here.
    
           CallYourConfigurationMethod();
           configured.Set() // Signal that configuration is complete.
    
           // Do some more stuff here.
        });
      worker.Start(); 
      configured.WaitOne();
      Application.EnableVisualStyles(); 
      Application.SetCompatibleTextRenderingDefault(true); 
      Application.Run(TaskBarIcon.getInstance()); 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .NET 2.0 targeted C# windows forms application that is running fine
I have a Windows Forms application (.NET 4) that runs fine on my development
I have developed a C# Windows Forms application that runs in the background as
I have a Windows Forms application that runs locally on the user's desktop. The
I have created a Windows Forms application in .NET 2 using C# that runs
I have a windows forms application that reads and updates an XML file with
I have a Windows Forms application that on it I have a RichTextBox, like
I have a Windows Forms application that uses some Application.Idle handlers to change the
If you have a windows service and a windows forms application that uses the
Scenario I have a C# windows forms application that has a number of processes.

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.