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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:21:18+00:00 2026-05-13T11:21:18+00:00

(I have a workaround for this problem, but it’s not the first time I’ve

  • 0

(I have a workaround for this problem, but it’s not the first time I’ve been bitten, so I’m trying to understand exactly what’s going on.)

  • From my application, I ShowDialog a form.
  • On the form is a button, which when clicked calls code on another (non-Gui) thread.
  • The non-GUI thread sends back statuses (Pushed then Released) via a Control.Invoke
  • When the form sees the Pushed, it invokes form.Hide()
  • When the form sees the Released, it changes the appearance of the button.

What happens is that sometimes, but not everytime, the non-Gui thread gets ‘stuck’ trying to send the Released. No exceptions, the Gui carries on ‘working’, but no further communication with the non-Gui thread is possible, in either direction.

The (simplified) callstack for the thread looks like this:

System.Threading.WaitHandle.WaitOne()
(...)
System.Windows.Forms.Control.WaitForWaitHandle()
(...)
System.Windows.Forms.Control.Invoke()
(...)
GuiCode.OnStatusChanged()
(...)
NonGuiCode.SetStatus()

The problem goes away if I replace ShowDialog with Show, but – interestingly – it gets better (happens less often) but doesn’t completely go away if I comment out the code that does the Hide on Pushed.

Update

Thanks to nobugz, I’ve discovered deadlock (I’d only ever met it in databases before)! Apparently replacing Control.Invoke with Control.BeginInvoke solves this problem (the status event still gets ‘stuck’ sometimes, but it doesn’t block all following communications).

  • 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-13T11:21:18+00:00Added an answer on May 13, 2026 at 11:21 am

    Clearly, you are battling deadlock. That’s always around the corner when you use Control.Invoke() instead of BeginInvoke(). It isn’t clear to me what trips the deadlock from your post. One red flag is using Hide() on a form that you displayed with ShowDialog(). That normally closes the dialog.

    Best thing to do is to debug it. Wait until the deadlock occurs, then use Debug + Break All. Use Debug + Windows + Threads and switch to the UI thread. Look at the Call Stack. If it is not pumping the message loop (Application.Run()) but is stuck somewhere (like the wait handle you appear to be using) then deadlock is the result.

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

Sidebar

Ask A Question

Stats

  • Questions 268k
  • Answers 268k
  • 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 You can use the really simple history library But if… May 13, 2026 at 12:59 pm
  • Editorial Team
    Editorial Team added an answer You should probably create an array of arrays, one for… May 13, 2026 at 12:59 pm
  • Editorial Team
    Editorial Team added an answer One way to get an exact answer is using infinite… May 13, 2026 at 12:59 pm

Related Questions

Update: Thanks for everyone who helped out - the answer to this one lay
I have a Wizard control with one of the pages containing a FileUpload control.
I can't get Safari to submit forms to a page that is protected by
I have a script that I'd like to continue using, but it looks like
I have a class, Fixture , that I want to cast to a 3rd

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.