Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had similar issue, and found the culprit in our code.</p> <p>Technique used: 0. Make sure in Spy++ that there are only two unmanaged threads with controls on them (WinForms and GDI+):</p> <pre><code>public static class ThreadingHelper_NativeMethods { [DllImport("user32.dll")] public static extern bool IsGUIThread(bool bConvert); } </code></pre> <p>call this from UI thread upon init:</p> <pre><code>// This code forces initialization of .NET BroadcastEventWindow to the UI thread. // http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/fb267827-1765-4bd9-ae2f-0abbd5a2ae22 if (ThreadingHelper_NativeMethods.IsGUIThread(false)) { Microsoft.Win32.SystemEvents.InvokeOnEventsThread(new MethodInvoker(delegate() { int x = 0; })); } </code></pre> <ol> <li><p>Remember managed id of Ui Thread in a singleton class.</p></li> <li><p>Search for all UserControls defined in our code. In each control's constructor, before calling InitializeComponent(), i placed code that checks current thread id against the main thread id. If they aren't equal, Assert(false).</p></li> <li><p>Subscribe to SystemEvents.UserPreferencesChanging. Debug.Assert(false) in handler: this happens before SystemEvents.UserPreferencesChanged, so debugger will hopefully pause here.</p></li> <li><p>Inspect list of subscribers to SystemEvents in the debugger. Find a subscriber in _handles dictionary of lists. Opening up SynchronizationContext of the each callback should reveal the problem: same thread id as for the control created on non-UI thread. SystemEvents will will execute event handler on that thread, deadlocking against UI thread.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload