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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:35:16+00:00 2026-05-13T15:35:16+00:00

This post is continuation of Way to quickly show/hide WinForms GUI C# , as

  • 0

This post is continuation of Way to quickly show/hide WinForms GUI C#, as it doesn’t work for me in this particular case.

I’ve got 2 problems:

  • 1 is that the mainAnnounceWindow gui should start hidden and later on when called by: windowStateChange(“Show”) it should show, by windowStateChange(“Hide”) it should hide. It doesn’t do that properly as when i start app it’s visible for like 0,5 s (i see it blinking). Is there a way to make it start hidden and not blink for half a second.

  • 2 is that windowStateChange doesn’t work properly when called from myThreadHandler (Queue.Work).

    internal class Program {
    public delegate void StateCallBack(string varState);
    public static readonly Announce mainAnnounceWindow = new Announce();
    public static readonly Thread myThreadGuiAnnounce = new Thread(showGuiAnnounce);
    public static readonly Thread myThreadTcpClient = new Thread(threadTcpClient);
    public static readonly Thread myThreadUdpMonitor = new Thread(threadUdpMonitor);
    public static readonly Thread myThreadHandler = new Thread(Queue.work);
    
    public static void Main() 
    {
        myThreadGuiAnnounce.Start();
        myThreadTcpClient.Start();
        myThreadUdpMonitor.Start();
        myThreadHandler.Start();
        windowStateChange("Hide");
    
        while (true) {
            Thread.Sleep(1000);
        }
    }
    public static void windowStateChange(string varState) {
        if (mainAnnounceWindow.InvokeRequired) {
            mainAnnounceWindow.Invoke(new StateCallBack(windowStateChange), new object[] {varState});
        } else {
            if (varState == "Hide") {
                mainAnnounceWindow.Hide();
                mainAnnounceWindow.TopMost = false;
            } else {
                mainAnnounceWindow.Show();
                mainAnnounceWindow.TopMost = true;
            }
        }
    }
        private static void showGuiAnnounce() {
        mainAnnounceWindow.ShowDialog();
    
    }
    }
    

Another class:

  public class Queue : IDisposable {
 public static void work() {
        while (true) {
            string task = null;
            lock (locker)
                if (tasks.Count > 0) {
                    task = tasks.Dequeue();
                    if (task == null) {
                        return;
                    }
                }
            if (task != null) {
                //MessageBox.Show("Performing task: " + task);
                Program.mainAnnounceWindow.setLogTextBox(task);
                Program.mainAnnounceWindow.setLogTrayTip(task);
                Program.windowStateChange("Show");
                Thread.Sleep(5000); // simulate work...
                Program.windowStateChange("Hide");
            } else {
                wh.WaitOne(); // No more tasks - wait for a signal
            }
        }
    }

}

The problem is with:

                Program.windowStateChange("Show");
                Thread.Sleep(5000); // simulate work...
                Program.windowStateChange("Hide");

When i call Program.windowStateChange(“Show”); from inside other thread the gui shows but not quite.. like i can see that it would like to show, but it doesn’t. Like a hang of app. But when the Thread.Sleep(5000) passes the app hides.

Calling:

                Program.mainAnnounceWindow.setLogTextBox(task);
                Program.mainAnnounceWindow.setLogTrayTip(task);

Has no problem. BaloonTip shows, just the Gui doesn’t show up properly. Something i’m doing wrong.

Oh and of course i did some cut/paste so it may miss some stuff. If it’s necessary to add something let me know.

With regards,

MadBoy

  • 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-13T15:35:17+00:00Added an answer on May 13, 2026 at 3:35 pm

    The problem is that your main thread is locked up, because you added this:

    while (true) { 
        Thread.Sleep(1000); 
    } 
    

    This will prevent the window thread from receiving and processing the windows messages (such as show and hide) appropriately.

    You’ll also want to use mainAnnounceWindow.Show(), not mainAnnounceWindow.ShowDialog(), as this will prevent control from returning properly to the main thread. You should just call Application.Run(mainAnnounceWindow) in your Main routine:

    public static void Main()       
    {      
        myThreadGuiAnnounce.Start();      
        myThreadTcpClient.Start();      
        myThreadUdpMonitor.Start();      
        myThreadHandler.Start();      
    
        // Just change your main window's load to hide itself... windowStateChange("Hide");      
        Application.Run(mainAnnounceWindow);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 310k
  • Answers 310k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Well, you override innerHTML in every step. Try: document.getElementById("pagination").innerHTML +=… May 13, 2026 at 10:08 pm
  • Editorial Team
    Editorial Team added an answer I just avoid the block comments and instead I select… May 13, 2026 at 10:08 pm
  • Editorial Team
    Editorial Team added an answer you can use CURLOPT_PROXY from PHP curl May 13, 2026 at 10:08 pm

Related Questions

This question is in continuation to my previous post located here . Since there
This question is in continuation of this post , I have tried installing Xerces-C
This is a continuation of the post How does one access a method from
This is a continuation of the question posted in: How to load a jar
Ok its a continuation of my crap attempts of using client side scripts along

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.