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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:22:16+00:00 2026-05-24T07:22:16+00:00

in the last hours I’ve struggled with delegates and accessing Windows Forms controls (C++)

  • 0

in the last hours I’ve struggled with delegates and accessing Windows Forms controls (C++) where I’ve used this tutorial (the first thread safe method): http://msdn.microsoft.com/en-us/library/ms171728.aspx#Y190

Changing TextBoxes and Labels works perfectly but when I want to show or hide the whole GUI from another thread this fails.

I use the following methode (which is part of the GUI class):

System::Void UI::showUI(boolean value) {
    if (this->InvokeRequired) {    
        SetTextDelegate^ d = gcnew SetTextDelegate(this, &UI::showUI);
        this->Invoke(d, gcnew array<Object^> { value });
    } else {
        if (value == true)
            this->Show();
        else
            this->Hide();
    }
}

In the first call the if-clause is true so Invoke is called. But usually the showUI method should be called a second time automatically where the if-clause returns false, but this is not happening. So the GUI is neither shown nor hiden.

Is it necessary to show/hide the GUI with a delegate or can I do it from every possible thread? If a delegate is necessary, why is showUI not executed a second time?

Thanks,
Martin

edit: okay the name SetTextDelegate is not appropriate but this is not the point…

  • 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-24T07:22:17+00:00Added an answer on May 24, 2026 at 7:22 am

    This is a pretty standard case of deadlock, not uncommon with Control::Invoke(). It can only proceed if the UI thread is not busy. Use Debug + Windows + Threads and double-click the Main thread. Look at the call stack to see what it is doing. The typical case is that it is blocking, waiting for the thread to finish the job. That will never happen since the thread can’t complete until the Invoke() call returns.

    Don’t block the UI thread.

    Consider using BackgroundWorker, its RunworkerCompleted event is nice to do stuff after the thread completes, removing the need to block.

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

Sidebar

Related Questions

I've been stuck with this simple Sql query for last 3 hours and my
I've been scratching my head about this for the last 4 hours, trying out
I've been having problems with this code I had spent the last 3 hours
I'm sure this has been answered before, but I've spent the last three hours
For the last few hours I've been trying to set up this http://code.google.com/apis/books/docs/dynamic-links.html on
I've spent the last 2 hours trying to find a solution for this and
I have been struggling for the last few hours trying to get this search
I have been spending the last hours trying to figure this out and now
I have spent the last 3 hours trying to get this code working. I
I've been looking around for the last couple hours on how to do this

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.