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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:34:12+00:00 2026-05-23T16:34:12+00:00

I have a WPF application that hosts a modeless Win32 form. Everything runs smoothly,

  • 0

I have a WPF application that hosts a modeless Win32 form. Everything runs smoothly, until I attach or detach VNC to the machine. Then the application deadlocks: It doesn’t redraw anything anymore, doesn’t react to user interaction. I’ve looked at the stack trace using WinDbg:

0012f03c 792b6865 System.Threading.WaitHandle.WaitOne(Int32, Boolean)
0012f050 7b6f1a4f System.Windows.Forms.Control.WaitForWaitHandle(System.Threading.WaitHandle)
0012f064 7ba2d68b System.Windows.Forms.Control.MarshaledInvoke(System.Windows.Forms.Control, System.Delegate, System.Object[], Boolean)
0012f104 7b6f33ac System.Windows.Forms.Control.Invoke(System.Delegate, System.Object[])
0012f138 7b920bd7 System.Windows.Forms.WindowsFormsSynchronizationContext.Send(System.Threading.SendOrPostCallback, System.Object)
0012f150 7a92ed62 Microsoft.Win32.SystemEvents+SystemEventInvokeInfo.Invoke(Boolean, System.Object[])
0012f184 7a92dc8f Microsoft.Win32.SystemEvents.RaiseEvent(Boolean, System.Object, System.Object[])
0012f1d0 7a92daec Microsoft.Win32.SystemEvents.OnDisplaySettingsChanging()
0012f1e0 7a574c9f Microsoft.Win32.SystemEvents.WindowProc(IntPtr, Int32, IntPtr, IntPtr)
0012f1e4 003c20dc [InlinedCallFrame: 0012f1e4] 
0012f3a8 57843a57 System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
0012f3f8 57843129 System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
0012f404 578430cc System.Windows.Threading.Dispatcher.Run()
0012f410 55bed46e System.Windows.Application.RunDispatcher(System.Object)
0012f41c 55bec76f System.Windows.Application.RunInternal(System.Windows.Window)
0012f440 55bd3aa6 System.Windows.Application.Run(System.Windows.Window)
0012f450 55bd3a69 System.Windows.Application.Run()

Apparently, the VNC attach/detach raises an OnDisplaySettingsChanging event, which in turn tries to call some event using System.Windows.Forms.Control.Invoke, which sends a message to the main thread and then waits for a response. But since this all happens in the main thread, the message loop never gets the message and the wait never returns.

I’ve found a workaround using EnableSystemEventsThreadAffinityCompatibility (which essentially bypasses the Control.Invoke call), but it feels like a dirty hack.

Did anybody ever see something like this happen?

Does someone have a clue why the SystemEvents class would use Control.Invoke when the message arrives on the main (STA) thread (it does, I checked)?

EDIT: Answers to questions in comments:

  • Does the same thing happen when changing display settings (e.g. res) without VNC? -> No.
  • Does the same thing happen with a couple of different versions on VNC (including hte latest)? -> I’ve only tried the latest version 1.0.9.5.
  • Any other details about the WPF app, controls, or Win32 contorls? -> There’s a WPF main window and a modeless WinForms Form.
  • 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-23T16:34:12+00:00Added an answer on May 23, 2026 at 4:34 pm

    This is a program initialization problem. Watch out for custom splash screens. If the first event subscription doesn’t happen on the main thread then it will fire notifications on the wrong thread. That can cause all kinds of nasty problems, ranging from odd painting artifacts to outright deadlock. Beware that several standard Winforms controls will use SystemEvents to know when they should repaint themselves when the Windows theme or system colors were changed.

    One workaround is to explicitly subscribe a dummy event handler in the Main() method, before anything else is done.

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

Sidebar

Related Questions

I have a WPF application that runs fine under XP as an administrator. When
I have a small WPF application that hosts a RichTextBox: <RichTextBox SpellCheck.IsEnabled=True FontFamily=Verdana AcceptsTab=True
I have a WPF application that runs as a service and renders 2D graphical
I have a keyboard focus problem with Windows Forms application that hosts WPF UserControls.
I have WPF application that has a login form. I would like to make
I have written a WPF application that I want to port to Silverlight 2.
I have a simple message box in a WPF application that is launched as
I have a WPF application embedded in a Microsoft Outlook 2003 window. Everything is
I have a WPF application where I'd like to create a custom pop-up that
I have a WPF application using MVVM. I have some user controls that show

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.