Link to home
Create AccountLog in
Avatar of Agarici
AgariciFlag for Romania

asked on

deadlock when using waitOne in a STA thread

Hi,

I have the problem described bellow with the calls to WaitHandle.WaitOne
causing re-entrancy on main GUI thread (STA) of a .NET application and I
would like to find out:
   - did anybody else run into the same problem?
   - is it a known issue? is there a fix for it?
   - is there a workaround for it?
   - if no fix/workaround I would like to find out the complete list of
messages that are being handled (dispatched by ole32.dll OLE/COM message
pump) when doing WaitOne on a STA thread.

The problem is:

I have 2 (or more) calls pending to execute on the main gui thread (I am
actually doing Invoke on some control)
the first call, at some point does WaitHandle.WaitOne.
at this point, if a Windows message comes to the app (like
WM_POPUPSYSTEMMENU - 0x0313 ) triggered by a right-click on the task bar
icon of the app the following happens:
    - the app processes this message
    - the app starts processing other pending messages - like my second
invoke
    - at this point my app is deadlocked, because it is not supposed to
enter the second call before finishing processing the first one.
    - also at this point the entire system is not behaving properly - for
example I cannot bring up any window by clicking on the taskbar icon
important note: if I would not do right click on the taskbar icon of my app,
and just let it work in background, everything would be ok.

After investigating this issue for a while, I found that WaitOne is not
actually a blocking call when called from an STA thread.

The only reference  I found related to this matter in  MSDN pages is here:
http://msdn.microsoft.com/en-us/library/74169f59.aspx .
Quoting from that page:
 "WaitHandle..::.WaitOne,WaitHandle..::.WaitAny, WaitHandle..::.WaitAll,
Monitor..::.Enter, Monitor..::.TryEnter, Thread..::.Join,
GC..::.WaitForPendingFinalizers, and so on are all responsive to
Thread..::.Interrupt and to Thread..::.Abort. Also, if your thread is in a
single-threaded apartment, all these managed blocking operations will
correctly pump messages in your apartment while your thread is blocked."

If the apartment state is STA this function actually creates a message loop
that is processing some events (for now I have been able to identify 2 of
them (WM_POPUPSYSTEMMENU and WM_ACTIVATEAPP).  The problem is that these
messages triggers processing of other messages in the queue (like the
registered messages used for invoke in .NET ).

I have attached a simplified application to demonstrate the issue. In this
app I have created a thread from where I am calling multiple times the same
function which is suppose to execute on the GUI thread.
I have put some console prints to show that it is executing another invoke
on the main thread even if it is supposed to stay in the wait.

Another thing, in my app the calls to some functions are not supposed to
re-enter (and we are protecting them with the waitOnes) but if I modified
the sample app (attached to this mail) to have a non-blocking re-entrancy ,
I noticed if I right click on the taskbar icon while the first call is in
waitOne, all the other calls will be executed before the first call ends -
this is actually easy to explain since the other calls are not processed by
the app message loop but they are processed by the message loop created by
the WaitOne. however I don't think this should be the normal behavior - that
is: when I invoke 3 calls on some thread, the order of execution should be
the order of the invokes.

waiting forward for your replies
A.




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
 
namespace DeadLockWaitOne
{    
    public partial class Form1 : Form
    {
        #region Designer
        private Button button1;
       
        public Form1()
        {
            InitializeComponent();
        }
 
        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(12, 12);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(86, 31);
            this.button1.TabIndex = 0;
            this.button1.Text = "button1";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // Form1
            // 
            this.ClientSize = new System.Drawing.Size(292, 273);
            this.Controls.Add(this.button1);
            this.Name = "Form1";
            this.ResumeLayout(false);
 
        }
        #endregion Designer
 
 
        #region My Code
        private void button1_Click(object sender, EventArgs e)
        {
            System.Threading.Thread t = new System.Threading.Thread(delegate()
            {
                test(1);
                test(2);
                test(3);
                test(4);
                test(5);
            }
            );
            t.IsBackground = true;
            t.Start();
        }
 
        private delegate void TestDelegate(int callNo);
        private static int enterCount = 0;
        private void test(int callNo)
        {
            Console.WriteLine("Entering... {0}", callNo);
            if ( this.InvokeRequired )
            {
                BeginInvoke(new TestDelegate(test), callNo);
                return;
            }
 
            int enterCountValue = Interlocked.Increment(ref enterCount);
            Console.WriteLine("Entered {0} - {1} time", callNo, enterCountValue);
            
            System.Threading.AutoResetEvent ev = new System.Threading.AutoResetEvent(false);
 
            // if you comment out the next line you will see that the order of execution changes - it becomes 2,3,4,5,1
            // i've put the if here to simulate the situation i have in my app.
            if ( enterCountValue == 1 )
            {
                System.Threading.Thread t = new System.Threading.Thread(delegate()
                {
                    Thread.Sleep(10000);
                    ev.Set();
                });
                t.IsBackground = true;
                t.Start();
            }
            ev.WaitOne();
 
            Console.WriteLine("Doing something meaningfull for call #{0}", callNo);
 
            Console.WriteLine("Exited {0} - {1} time", callNo, enterCountValue);
            enterCountValue = Interlocked.Decrement(ref enterCount);
        }
        #endregion My Code
    }
    
    
    public class Program
    {
        [STAThread]
        public static void Main(string[] args)
        {
            System.Windows.Forms.Application.Run(new Form1());
        }
    }
 
}

Open in new window

Avatar of p_davis
p_davis

try placing  ev.WaitOne();

at the top of your method.
sorry -- ignore my last post
place the definition of the thread as a class member instead of a local-- each time you enter that method you are creating a new ev.-- that may be why it isn't waiting
Avatar of Agarici

ASKER

no difference - in may app it is like you say - the code i posted is quickly created to reproduce the same problem i have in my app (which is much larger and cannot post it here)

the thing is it processes the invokes normally as long as no other message comes to the main window. if a message comes - like the one generated by the right click on the taskbar - it processes the next event even thow the previous invoke did not finish. i discovered that's because of the message loop created by the waitOne.
what is even interesting, if the reentrancy is not blocking, the order of executing the 5 invokes will not be 1,2,3,4,5 - it will change to be 2,3,4,5,1
in my posted test code you can achieve this by commenting the 'if ( enterCountValue == 1 )' line. in this case you will see the output in the console beeig:

Doing something meaningfull for call #2
Doing something meaningfull for call #3
Doing something meaningfull for call #4
Doing something meaningfull for call #5
Doing something meaningfull for call #1

Regards,
A.
you could always use a mutex instead of relying on the threads wait one i tested and it gave 12345.

class member mutex -- waitone at the beginning of the method and the releasemutex at the end.
Avatar of Agarici

ASKER

it gave 12345 if you don't interfere. if while in the first wait you right-click on the taskbar icon, it will change like i said.
that is because only when you right click on the taskbar the system message comes to the app and generates the processing of the second pending invoke

changing the code like you said is not an option - i did not test it yet, but it's imposible for me to go changing all the code in our app like that. the are thousands of places where we rely on the WaitOne. we cannot workaround this issue everywhere.
i doing some reading of examples -- it looks like you have to set again to  signal that the processing is done-- i tried to follow your steps to recreate the issue after i added the second ev.Set(); i wasn't able to recreate -- maybe you can -- but it is worth a try.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
 
namespace DeadLockWaitOne
{    
    public partial class Form1 : Form
    {
        #region Designer
        private Button button1;
       
        public Form1()
        {
            InitializeComponent();
        }
 
        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(12, 12);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(86, 31);
            this.button1.TabIndex = 0;
            this.button1.Text = "button1";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // Form1
            // 
            this.ClientSize = new System.Drawing.Size(292, 273);
            this.Controls.Add(this.button1);
            this.Name = "Form1";
            this.ResumeLayout(false);
 
        }
        #endregion Designer
 
 
        #region My Code
        private void button1_Click(object sender, EventArgs e)
        {
            System.Threading.Thread t = new System.Threading.Thread(delegate()
            {
                test(1);
                test(2);
                test(3);
                test(4);
                test(5);
            }
            );
            t.IsBackground = true;
            t.Start();
        }
 
        private delegate void TestDelegate(int callNo);
        private static int enterCount = 0;
        private void test(int callNo)
        {
            Console.WriteLine("Entering... {0}", callNo);
            if ( this.InvokeRequired )
            {
                BeginInvoke(new TestDelegate(test), callNo);
                return;
            }
 
            int enterCountValue = Interlocked.Increment(ref enterCount);
            Console.WriteLine("Entered {0} - {1} time", callNo, enterCountValue);
            
            System.Threading.AutoResetEvent ev = new System.Threading.AutoResetEvent(false);
 
            // if you comment out the next line you will see that the order of execution changes - it becomes 2,3,4,5,1
            // i've put the if here to simulate the situation i have in my app.
            if ( enterCountValue == 1 )
            {
                System.Threading.Thread t = new System.Threading.Thread(delegate()
                {
                    Thread.Sleep(10000);
                    ev.Set();
                });
                t.IsBackground = true;
                t.Start();
            }
            ev.WaitOne();
 
            Console.WriteLine("Doing something meaningfull for call #{0}", callNo);
 
            Console.WriteLine("Exited {0} - {1} time", callNo, enterCountValue);
            enterCountValue = Interlocked.Decrement(ref enterCount);
            
            ev.Set(); //<----------------------------------------------------ADDED HERE
        }
        #endregion My Code
    }
    
    
    public class Program
    {
        [STAThread]
        public static void Main(string[] args)
        {
            System.Windows.Forms.Application.Run(new Form1());
        }
    }
 
}

Open in new window

I'll go out on a limb and say that link about WaitOne yielding to the mesage pump is either wrong or doesn't apply in this situation.  I built your code with a 60 second delay instead of 10 and watched it in the debugger.  It works exactly as I would expect.  The button click creates a thread using a multicast delegate.  Each call to test from that thread runs and does the invoke, queueing up the request on the message pump.  The first invoke happening on the main thread goes into the 60 second wait, and when it finishes the 60 seconds it completes and the second call is pulled from the pump.  Etc., for the remaining calls.  I could see that any external events, such as a button click could certainly happen in the middle of the 5 calls and mess things up.  Does this sound right and if so can you clarify your problem/question?
I see my last couple lines weren't clear.  Other events can get put in the queue in the middle of the worker threads adding their test calls to the queue, but these events won't interrupt the Wait call and in your example they won't cause reentrant calls on your test method.
Avatar of Agarici

ASKER

hi.
First, i'm sorry if my post is so long - i cannot express everything in just a few words.

mastoo, they are beeing processed by the message pump of WaitOne. when i simply let the app run without any intervention, i get the folowing output:

Entering... 1
Entering... 2
Entering... 3
Entering... 4
Entering... 5
Entering... 1
Entered 1 - 1 time
Doing something meaningfull for call #1
Exited 1 - 1 time
Entering... 2
Entered 2 - 1 time
Doing something meaningfull for call #2
Exited 2 - 1 time
Entering... 3
Entered 3 - 1 time
Doing something meaningfull for call #3
Exited 3 - 1 time
Entering... 4
Entered 4 - 1 time
Doing something meaningfull for call #4
Exited 4 - 1 time
Entering... 5
Entered 5 - 1 time
Doing something meaningfull for call #5
Exited 5 - 1 time

if while waiting in the first invoke i right click on the taskbar icon of the app i get this (please notice the order the invokes get executed - the order of messages 'Doing something meaningfull for call #X'):

Entering... 1
Entering... 2
Entering... 3
Entering... 4
Entering... 5
Entering... 1
Entered 1 - 1 time
Entering... 2
Entered 2 - 2 time
Doing something meaningfull for call #2
Exited 2 - 2 time
Entering... 3
Entered 3 - 2 time
Doing something meaningfull for call #3
Exited 3 - 2 time
Entering... 4
Entered 4 - 2 time
Doing something meaningfull for call #4
Exited 4 - 2 time
Entering... 5
Entered 5 - 2 time
Doing something meaningfull for call #5
Exited 5 - 2 time
Doing something meaningfull for call #1
Exited 1 - 1 time

also notice that when i right click on the taskbar icon while the STA thread is in the wait one, the seccond invoke starts executing before the first has finished:

......
Entering... 1
Entered 1 - 1 time
Entering... 2
Entered 2 - 2 time
Doing something meaningfull for call #2
Exited 2 - 2 time
......

if i stop in the debugger at this point i see this stack (i've marked with '>>>' the 2 calls to Form1.test on the stack - notice how the second one starts from the waitOne):
       [In a sleep, wait, or join]      
       mscorlib.dll!System.Threading.WaitHandle.WaitOne(long timeout, bool exitContext) + 0x2e bytes      
       mscorlib.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout, bool exitContext) + 0x23 bytes      
       mscorlib.dll!System.Threading.WaitHandle.WaitOne() + 0xa bytes      
>>>>DeadLockWaitOne.exe!DeadLockWaitOne.Form1.test(int callNo = 2) Line 92 + 0xb bytes      C#
       mscorlib.dll!System.Delegate.DynamicInvokeImpl(object[] args) + 0x5a bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackDo(System.Windows.Forms.Control.ThreadMethodEntry tme) + 0x9d bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(object obj) + 0x6b bytes      
       mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) + 0x43 bytes      
       mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0xa7 bytes      
       mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x92 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallback(System.Windows.Forms.Control.ThreadMethodEntry tme) + 0x90 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbacks() + 0xb3 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0x800 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m) + 0x45 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.WndProc(ref System.Windows.Forms.Message m) + 0x13 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Form.WndProc(ref System.Windows.Forms.Message m) + 0x2b6 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) + 0xd bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0xd6 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg = 49961, System.IntPtr wparam, System.IntPtr lparam) + 0x75 bytes      
       [Native to Managed Transition]      
       user32.dll!_InternalCallWinProc@20()  + 0x28 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DefWndProc(ref System.Windows.Forms.Message m = {System.Windows.Forms.Message}) + 0x94 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Form.DefWndProc(ref System.Windows.Forms.Message m) + 0x87 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0x87a bytes      
       System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m) + 0x45 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.WndProc(ref System.Windows.Forms.Message m) + 0x13 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Form.WndProc(ref System.Windows.Forms.Message m) + 0x2b6 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) + 0xd bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0xd6 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg = 787, System.IntPtr wparam, System.IntPtr lparam) + 0x75 bytes      
       [Native to Managed Transition]      
       user32.dll!_InternalCallWinProc@20()  + 0x28 bytes      
       mscorlib.dll!System.Threading.WaitHandle.WaitOne(long timeout, bool exitContext) + 0x2e bytes      
       mscorlib.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout, bool exitContext) + 0x23 bytes      
       mscorlib.dll!System.Threading.WaitHandle.WaitOne() + 0xa bytes      
>>>>DeadLockWaitOne.exe!DeadLockWaitOne.Form1.test(int callNo = 1) Line 92 + 0xb bytes      C#
       mscorlib.dll!System.Delegate.DynamicInvokeImpl(object[] args) + 0x5a bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackDo(System.Windows.Forms.Control.ThreadMethodEntry tme) + 0x9d bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(object obj) + 0x6b bytes      
       mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) + 0x43 bytes      
       mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0xa7 bytes      
       mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x92 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallback(System.Windows.Forms.Control.ThreadMethodEntry tme) + 0x90 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbacks() + 0xb3 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) + 0x800 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.ScrollableControl.WndProc(ref System.Windows.Forms.Message m) + 0x45 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.WndProc(ref System.Windows.Forms.Message m) + 0x13 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Form.WndProc(ref System.Windows.Forms.Message m) + 0x2b6 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.OnMessage(ref System.Windows.Forms.Message m) + 0xd bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Control.ControlNativeWindow.WndProc(ref System.Windows.Forms.Message m) + 0xd6 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg = 49961, System.IntPtr wparam, System.IntPtr lparam) + 0x75 bytes      
       [Native to Managed Transition]      
       user32.dll!_InternalCallWinProc@20()  + 0x28 bytes      
       user32.dll!_UserCallWinProcCheckWow@32()  + 0xb7 bytes      
       user32.dll!_DispatchMessageWorker@8()  + 0xdc bytes      
       user32.dll!_DispatchMessageW@4()  + 0xf bytes      
       [Managed to Native Transition]      
       System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int dwComponentID, int reason = -1, int pvLoopData = 0) + 0x2ea bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason = -1, System.Windows.Forms.ApplicationContext context = {System.Windows.Forms.ApplicationContext}) + 0x17d bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) + 0x53 bytes      
       System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) + 0x2e bytes      
       DeadLockWaitOne.exe!DeadLockWaitOne.Program.Main(string[] args = {Dimensions:[0]}) Line 108 + 0x1a bytes      C#
       mscoree.dll!__CorExeMain@0()  + 0x34 bytes      
       kernel32.dll!_BaseProcessStart@4()  + 0x23 bytes      


now, if i look into the unmanaged stack to see why it has processed something else while doing waitOne i see the stack bellow. sorry it's so long. notice how after each WaitOne a meesage loop is started and also notice the message that is processed by this meesage loop while in WaitOne. i've also marked with >>> the lines with the calls to Form1.test

OS Thread Id: 0x144c (5196)
Current frame: _KiFastSystemCallRet@0
ChildEBP RetAddr  Caller,Callee
0012c250 7c90df2c _NtWaitForMultipleObjects@20+0xc
0012c254 7c809574 _WaitForMultipleObjectsEx@20+0x12c, calling _NtWaitForMultipleObjects@20
0012c280 7e4193e9 _NtUserPeekMessage@20+0xc
0012c284 7e4193a8 __PeekMessage@24+0x74, calling _NtUserPeekMessage@20
0012c2ac 7e419402 _PeekMessageW@20+0xbc, calling __PeekMessage@24
0012c2d8 7755b2bc ?MyPeekMessage@CCliModalLoop@@QAEHPAUtagMSG@@PAUHWND__@@IIG@Z+0x30, calling _PeekMessageW@20
0012c2f0 7e4195f9 _RealMsgWaitForMultipleObjectsEx@20+0x13e, calling _WaitForMultipleObjectsEx@20
0012c31c 7752f0b8 ?MyPeekMessage@CCliModalLoop@@QAEHPAUtagMSG@@PAUHWND__@@IIG@Z+0xa1, calling __SEH_epilog
0012c320 7752f0f0 ?PeekRPCAndDDEMessage@CCliModalLoop@@AAEHXZ+0x30, calling ?MyPeekMessage@CCliModalLoop@@QAEHPAUtagMSG@@PAUHWND__@@IIG@Z
0012c34c 7752ebd6 ?BlockFn@CCliModalLoop@@QAEJPAPAXKPAK@Z+0x80, calling _MsgWaitForMultipleObjectsEx@20
0012c374 77557237 _CoWaitForMultipleHandles@20+0xcf, calling ?BlockFn@CCliModalLoop@@QAEJPAPAXKPAK@Z
0012c3e8 79f27b88 ?NT5WaitRoutine@@YGKHKHPAPAXH@Z+0x51, calling _CoWaitForMultipleHandles@20
0012c400 79f17565 ?GetFinalApartment@Thread@@QAE?AW4ApartmentState@1@XZ+0x8d, calling __EH_epilog3
0012c408 79f27acf ?MsgWaitHelper@@YGKHPAPAXHKH@Z+0xa5, calling ?NT5WaitRoutine@@YGKHKHPAPAXH@Z
0012c45c 79f17565 ?GetFinalApartment@Thread@@QAE?AW4ApartmentState@1@XZ+0x8d, calling __EH_epilog3
0012c474 79f27a33 ?DoAppropriateAptStateWait@Thread@@AAEKHPAPAXHKW4WaitMode@@@Z+0x28, calling ?MsgWaitHelper@@YGKHPAPAXHKH@Z
0012c494 79f17493 ?DoAppropriateWaitWorker@Thread@@AAEKHPAPAXHKW4WaitMode@@@Z+0x144, calling ?DoAppropriateAptStateWait@Thread@@AAEKHPAPAXHKW4WaitMode@@@Z
0012c518 79f1732f ?DoAppropriateWait@Thread@@QAEKHPAPAXHKW4WaitMode@@PAUPendingSync@@@Z+0x40, calling ?DoAppropriateWaitWorker@Thread@@AAEKHPAPAXHKW4WaitMode@@@Z
0012c550 79ef5723 ?AcquireSafeHandle@@YGXPAPAVSafeHandle@@@Z+0x35, calling __EH_epilog3
0012c568 7a07b49c ?CorWaitOneNative@WaitHandleNative@@SIHPAVSafeHandle@@H_N1@Z+0x14e, calling ?DoAppropriateWait@Thread@@QAEKHPAPAXHKW4WaitMode@@PAUPendingSync@@@Z
0012c5c4 7a07b2dd ?CorWaitOneNative@WaitHandleNative@@SIHPAVSafeHandle@@H_N1@Z+0x21, calling @LazyMachStateCaptureState@4
0012c628 7a080550 ?Start@ThreadNative@@SIXPAVThreadBaseObject@@PAVObject@@PAW4StackCrawlMark@@@Z+0x1f, calling @LazyMachStateCaptureState@4
0012c66c 793d424e (MethodDesc 0x7924ad60 +0x2e System.Threading.WaitHandle.WaitOne(Int64, Boolean)), calling ?CorWaitOneNative@WaitHandleNative@@SIHPAVSafeHandle@@H_N1@Z
0012c684 793d4193 (MethodDesc 0x7924ad48 +0x23 System.Threading.WaitHandle.WaitOne(Int32, Boolean)), calling (MethodDesc 0x7924ad60 +0 System.Threading.WaitHandle.WaitOne(Int64, Boolean))
0012c698 793d420e (MethodDesc 0x7924ad58 +0xa System.Threading.WaitHandle.WaitOne())
>>>>0012c6a0 012305e7 (MethodDesc 0x925928 +0x1cf DeadLockWaitOne.Form1.test(Int32))
0012c6c0 7b07a706 (MethodDesc 0x7b5a8180 +0xd6 System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)), calling 0093704e
0012c6d0 7b08b889 (MethodDesc 0x7b4a7d70 +0xb9 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr, Int32, IntPtr, IntPtr)), calling  (JitHelp: CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE)
0012c6f0 79e7c2ca ?SkipExactlyOne@SigParser@@QAEJXZ+0x20, calling ?CorSigEatCustomModifiersAndUncompressElementType@@YGJPAPBEKPAKPAW4CorElementType@@@Z
0012c720 79e88f63 _CallDescrWorker@20+0x33
0012c730 79e88ee4 _CallDescrWorkerWithHandler@24+0xa3, calling _CallDescrWorker@20
0012c7b0 79e88e31 ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0x19c, calling _CallDescrWorkerWithHandler@24
0012c7e0 79e88fe3 ??0MetaSig@@QAE@PAV0@@Z+0x38, calling _memcpy
0012c7ec 79e88db3 ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0xaf, calling ?addition@?$ClrSafeInt@I@@SG_NIIAAI@Z
0012c7f8 79e88dc3 ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0xbb, calling __alloca_probe_16
0012c85c 79e74c1c ?Alloc@@YGPAVObject@@IHH@Z+0x60
0012c874 79f18839 ?JIT_MonReliableEnter@@YIXPAVObject@@PA_N@Z+0x25, calling @LazyMachStateCaptureState@4
0012c878 79e74ebd ?LazyInit@HelperMethodFrame@@IAEXPAXPAULazyMachState@@@Z+0x17, calling  (JitHelp: CORINFO_HELP_GET_THREAD)
0012c890 79e8a1af ??0HelperMethodFrame_1OBJ@@QAE@PAXPAULazyMachState@@IPAPAVObject@@@Z+0x14, calling ??0HelperMethodFrame@@QAE@PAXPAULazyMachState@@I@Z
0012c8ac 79e88d3b ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0x1f, calling __alloca_probe_16
0012c8f0 79e88d19 ?CallTargetWorker@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KH@Z+0x20, calling ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z
0012c908 79e88cf6 ?Call@MethodDescCallSite@@QAEXPB_K@Z+0x18, calling ?CallTargetWorker@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KH@Z
0012c91c 7a11ae16 ?InvokeImpl@@YGPAVObject@@PAVMethodDesc@@PAV1@PAVPtrArray@@PAUSignatureNative@@KVTypeHandle@@@Z+0x43f, calling ?Call@MethodDescCallSite@@QAEXPB_K@Z
0012c938 7a11ac68 ?InvokeImpl@@YGPAVObject@@PAVMethodDesc@@PAV1@PAVPtrArray@@PAUSignatureNative@@KVTypeHandle@@@Z+0x28e, calling __alloca_probe_16
0012c9b0 003521f6 003521f6, calling ?DoUMThunkCall@@YG_JPAVThread@@PAVUMThkCallFrame@@@Z
0012caac 79e74c1c ?Alloc@@YGPAVObject@@IHH@Z+0x60
0012cac4 79f18839 ?JIT_MonReliableEnter@@YIXPAVObject@@PA_N@Z+0x25, calling @LazyMachStateCaptureState@4
0012cac8 79e74ebd ?LazyInit@HelperMethodFrame@@IAEXPAXPAULazyMachState@@@Z+0x17, calling  (JitHelp: CORINFO_HELP_GET_THREAD)
0012cae0 79e8a1af ??0HelperMethodFrame_1OBJ@@QAE@PAXPAULazyMachState@@IPAPAVObject@@@Z+0x14, calling ??0HelperMethodFrame@@QAE@PAXPAULazyMachState@@I@Z
0012cb04 7a11b0fa ?InvokeMethodFast@RuntimeMethodHandle@@SIPAVObject@@PAPAVMethodDesc@@PAV2@PAXKPAUSignatureNative@@PAVPtrArray@@@Z+0xbd, calling ?InvokeImpl@@YGPAVObject@@PAVMethodDesc@@PAV1@PAVPtrArray@@PAUSignatureNative@@KVTypeHandle@@@Z
0012cb60 7a11b05e ?InvokeMethodFast@RuntimeMethodHandle@@SIPAVObject@@PAPAVMethodDesc@@PAV2@PAXKPAUSignatureNative@@PAVPtrArray@@@Z+0x24, calling @LazyMachStateCaptureState@4
0012cbc4 793cf629 (MethodDesc 0x79248640 +0x49 System.RuntimeMethodHandle.InvokeMethodFast(System.Object, System.Object[], System.Signature, System.Reflection.MethodAttributes, System.RuntimeTypeHandle)), calling ?InvokeMethodFast@RuntimeMethodHandle@@SIPAVObject@@PAPAVMethodDesc@@PAV2@PAXKPAUSignatureNative@@PAVPtrArray@@@Z
0012cc10 794012bf (MethodDesc 0x79242888 +0x167 System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo, Boolean)), calling (MethodDesc 0x79248640 +0 System.RuntimeMethodHandle.InvokeMethodFast(System.Object, System.Object[], System.Signature, System.Reflection.MethodAttributes, System.RuntimeTypeHandle))
0012cc48 793ac0fa (MethodDesc 0x7923bbd8 +0x5a System.Delegate.DynamicInvokeImpl(System.Object[])), calling (MethodDesc 0x79242888 +0 System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo, Boolean))
0012cc70 7b06ec1d (MethodDesc 0x7b5a5f80 +0x9d System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry))
0012cc74 79362186 (MethodDesc 0x7924b598 +0x3e System.Threading.SynchronizationContext.SetSynchronizationContext(System.Threading.SynchronizationContext)), calling (MethodDesc 0x7913f578 +0 System.Threading.SynchronizationContext.SetSynchronizationContext(System.Threading.SynchronizationContext, System.Threading.SynchronizationContext))
0012cc94 7b06eca7 (MethodDesc 0x7b5a5f78 +0x6b System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(System.Object)), calling (MethodDesc 0x7b5a5f80 +0 System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry))
0012ccc0 793685af (MethodDesc 0x7913f3e0 +0x43 System.Threading.ExecutionContext.runTryCode(System.Object))
0012ccd0 79e88f63 _CallDescrWorker@20+0x33
0012cce0 79e88ee4 _CallDescrWorkerWithHandler@24+0xa3, calling _CallDescrWorker@20
0012cd60 79e88e31 ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0x19c, calling _CallDescrWorkerWithHandler@24
0012cd90 79e88fe3 ??0MetaSig@@QAE@PAV0@@Z+0x38, calling _memcpy
0012cd9c 79e88db3 ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0xaf, calling ?addition@?$ClrSafeInt@I@@SG_NIIAAI@Z
0012cda8 79e88dc3 ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0xbb, calling __alloca_probe_16
0012ce0c 79e8a69e ?Cleanup@CleanupWorkList@@QAGXH@Z+0x79d, calling @__security_check_cookie@4
0012ce24 79f293b7 ?DoUMThunkCallWorker@@YG_JPAVThread@@PAVUMThkCallFrame@@PBVUMEntryThunk@@PAVUMThunkMarshInfo@@PAUUMThunkMLStub@@@Z+0x260, calling __EH_epilog3_GS
0012ce28 79f29143 ?DoUMThunkCall@@YG_JPAVThread@@PAVUMThkCallFrame@@@Z+0x38b, calling ?DoUMThunkCallWorker@@YG_JPAVThread@@PAVUMThkCallFrame@@PBVUMEntryThunk@@PAVUMThunkMarshInfo@@PAUUMThunkMLStub@@@Z
0012ce5c 79e88d3b ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0x1f, calling __alloca_probe_16
0012cea0 79e88d19 ?CallTargetWorker@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KH@Z+0x20, calling ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z
0012ceb8 79e88cf6 ?Call@MethodDescCallSite@@QAEXPB_K@Z+0x18, calling ?CallTargetWorker@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KH@Z
0012cecc 79ef80d3 ?ExecuteCodeWithGuaranteedCleanupHelper@@YGXPAUECWGC_GC@@@Z+0xb2, calling ?Call@MethodDescCallSite@@QAEXPB_K@Z
0012cf94 79e88805 ?SizeOf@SigPointer@@QBEIPAVModule@@PBVSigTypeContext@@@Z+0x106, calling __EH_epilog3
0012cf98 79e816f7 ?GetReturnTypeSize@MetaSig@@QAEIXZ+0x17, calling ?SizeOf@SigPointer@@QBEIPAVModule@@PBVSigTypeContext@@@Z
0012cfa0 79e88888 ?CalculateHasFPReturn@MetaSig@@QAEXXZ+0x8, calling ?GetReturnTypeNormalized@MetaSig@@QBE?AW4CorElementType@@XZ
0012cfa8 79e88a0d ?ForceSigWalk@MetaSig@@QAEXH@Z+0x19d, calling ?CalculateHasFPReturn@MetaSig@@QAEXXZ
0012d040 79e8a69e ?Cleanup@CleanupWorkList@@QAGXH@Z+0x79d, calling @__security_check_cookie@4
0012d058 79f293b7 ?DoUMThunkCallWorker@@YG_JPAVThread@@PAVUMThkCallFrame@@PBVUMEntryThunk@@PAVUMThunkMarshInfo@@PAUUMThunkMLStub@@@Z+0x260, calling __EH_epilog3_GS
0012d05c 79f29143 ?DoUMThunkCall@@YG_JPAVThread@@PAVUMThkCallFrame@@@Z+0x38b, calling ?DoUMThunkCallWorker@@YG_JPAVThread@@PAVUMThkCallFrame@@PBVUMEntryThunk@@PAVUMThunkMarshInfo@@PAUUMThunkMLStub@@@Z
0012d098 79ef7fde ?ExecuteCodeWithGuaranteedCleanup@ReflectionInvocation@@SIXPAVObject@@00@Z+0xf9, calling ?ExecuteCodeWithGuaranteedCleanupHelper@@YGXPAUECWGC_GC@@@Z
0012d0e0 79ef7f1e ?ExecuteCodeWithGuaranteedCleanup@ReflectionInvocation@@SIXPAVObject@@00@Z+0x28, calling @LazyMachStateCaptureState@4
0012d148 793684fb (MethodDesc 0x7913f3d8 +0xa7 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)), calling ?ExecuteCodeWithGuaranteedCleanup@ReflectionInvocation@@SIXPAVObject@@00@Z
0012d160 793683ee (MethodDesc 0x7913f3d0 +0x92 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)), calling (MethodDesc 0x7913f3d8 +0 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))
0012d178 7b06ed78 (MethodDesc 0x7b4a6450 +0x90 System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry)), calling (MethodDesc 0x7913f3d0 +0 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))
0012d194 7b06ea6b (MethodDesc 0x7b5a5f88 +0xb3 System.Windows.Forms.Control.InvokeMarshaledCallbacks()), calling (MethodDesc 0x7b4a6450 +0 System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry))
0012d1cc 7b072f30 (MethodDesc 0x7b5a5a50 +0x800 System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)), calling (MethodDesc 0x7b5a5f88 +0 System.Windows.Forms.Control.InvokeMarshaledCallbacks())
0012d230 7b07f795 (MethodDesc 0x7b5a5588 +0x45 System.Windows.Forms.ScrollableControl.WndProc(System.Windows.Forms.Message ByRef)), calling (MethodDesc 0x7b5a5a50 +0 System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef))
0012d238 7b07f743 (MethodDesc 0x7b4a5910 +0x13 System.Windows.Forms.ContainerControl.WndProc(System.Windows.Forms.Message ByRef)), calling (MethodDesc 0x7b5a5588 +0 System.Windows.Forms.ScrollableControl.WndProc(System.Windows.Forms.Message ByRef))
0012d23c 7b063fc6 (MethodDesc 0x7b4a5550 +0x2b6 System.Windows.Forms.Form.WndProc(System.Windows.Forms.Message ByRef)), calling (MethodDesc 0x7b4a5910 +0 System.Windows.Forms.ContainerControl.WndProc(System.Windows.Forms.Message ByRef))
0012d24c 7b07a72d (MethodDesc 0x7b5a8168 +0xd System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef))
0012d250 7b07a706 (MethodDesc 0x7b5a8180 +0xd6 System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)), calling 0093704e
0012d264 7b08b845 (MethodDesc 0x7b4a7d70 +0x75 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr, Int32, IntPtr, IntPtr))
0012d28c 7a4a6956 (MethodDesc 0x7a7ffbb8 +0x26 System.ComponentModel.EventHandlerList.get_Item(System.Object)), calling (MethodDesc 0x7a7ffbe0 +0 System.ComponentModel.EventHandlerList.Find(System.Object))
0012d2a4 79e88f63 _CallDescrWorker@20+0x33
0012d2b4 7b05f80e (MethodDesc 0x7b4a6478 +0x32 System.Windows.Forms.Control.NotifyInvalidate(System.Drawing.Rectangle))
0012d2c0 79e88ee4 _CallDescrWorkerWithHandler@24+0xa3, calling _CallDescrWorker@20
0012d340 79f2905b ?ForwardCallToManagedMethod@@YG_KPBEPA_KIHPAVMetaSig@@PAUArgumentRegisters@@PAXPAEIPAUUnmanagedToManagedCallGCInfo@@@Z+0x55, calling _CallDescrWorkerWithHandler@24
0012d360 79f29369 ?DoUMThunkCallWorker@@YG_JPAVThread@@PAVUMThkCallFrame@@PBVUMEntryThunk@@PAVUMThunkMarshInfo@@PAUUMThunkMLStub@@@Z+0x1e5, calling ?ForwardCallToManagedMethod@@YG_KPBEPA_KIHPAVMetaSig@@PAUArgumentRegisters@@PAXPAEIPAUUnmanagedToManagedCallGCInfo@@@Z
0012d3c8 79f29249 ?DoUMThunkCallWorker@@YG_JPAVThread@@PAVUMThkCallFrame@@PBVUMEntryThunk@@PAVUMThunkMarshInfo@@PAUUMThunkMLStub@@@Z+0xc3, calling __alloca_probe_16
0012d404 7b0814c3 (MethodDesc 0x7b5ab7c0 +0x2b System.Windows.Forms.Button.WndProc(System.Windows.Forms.Message ByRef)), calling (MethodDesc 0x7b5aba60 +0 System.Windows.Forms.ButtonBase.WndProc(System.Windows.Forms.Message ByRef))
0012d40c 7b07a72d (MethodDesc 0x7b5a8168 +0xd System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef))
0012d410 7b07a706 (MethodDesc 0x7b5a8180 +0xd6 System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)), calling 0093704e
0012d464 79f29143 ?DoUMThunkCall@@YG_JPAVThread@@PAVUMThkCallFrame@@@Z+0x38b, calling ?DoUMThunkCallWorker@@YG_JPAVThread@@PAVUMThkCallFrame@@PBVUMEntryThunk@@PAVUMThunkMarshInfo@@PAUUMThunkMLStub@@@Z
0012d498 7c949a41 _RtlAllocateHeapSlowly@12+0xd7c, calling _RtlFillMemoryUlong@12
0012d4a0 7c91925d _RtlAllocateHeapSlowly@12+0xdc1, calling _RtlpGetExtraStuffPointer@4
0012d4a4 7c9192ef _RtlAllocateHeapSlowly@12+0x113b, calling __SEH_epilog
0012d4f0 79f75cc2 ?RareDisablePreemptiveGC@Thread@@QAEXXZ+0x3c6, calling _RtlRestoreLastWin32Error@4
0012d528 79fdfe26 _StubRareDisableTHROWWorker@8+0x5d, calling ?HandleThreadAbort@Thread@@QAEXH@Z
0012d52c 79fdfe35 _StubRareDisableTHROWWorker@8+0x6c, calling  (JitHelp: CORINFO_HELP_GET_THREAD)
0012d53c 003521f6 003521f6, calling ?DoUMThunkCall@@YG_JPAVThread@@PAVUMThkCallFrame@@@Z
0012d56c 7e418734 _InternalCallWinProc@20+0x28
0012d58c 7e418734 _InternalCallWinProc@20+0x28
0012d5b8 7e418816 _UserCallWinProcCheckWow@32+0x150, calling _InternalCallWinProc@20
0012d608 7e42b372 _DispatchHookW@16+0x31
0012d620 7e428ea0 _DispatchClientMessage@20+0xa3, calling _UserCallWinProcCheckWow@32
0012d65c 7e42b326 _CallHookWithSEH@16+0x44, calling __SEH_epilog
0012d674 7e428eec ___fnDWORD@4+0x24
0012d6c0 7e4194be _NtUserMessageCall@28+0xc
0012d6f0 79fdfe35 _StubRareDisableTHROWWorker@8+0x6c, calling  (JitHelp: CORINFO_HELP_GET_THREAD)
0012d700 003521f6 003521f6, calling ?DoUMThunkCall@@YG_JPAVThread@@PAVUMThkCallFrame@@@Z
0012d714 7e428dd9 _RealDefWindowProcW@16+0x47, calling _RealDefWindowProcWorker@20
0012d730 7e428d77 _DefWindowProcW@16+0x72, calling _RealDefWindowProcW@16
0012d778 7e418734 _InternalCallWinProc@20+0x28
0012d7a4 7e418816 _UserCallWinProcCheckWow@32+0x150, calling _InternalCallWinProc@20
0012d7f4 79e8e1cf ?HandleThreadAbort@Thread@@QAEXH@Z+0xa1, calling __EH_epilog3
0012d80c 7e42a013 _CallWindowProcAorW@24+0x98, calling _UserCallWinProcCheckWow@32
0012d83c 7e42a039 _CallWindowProcW@20+0x1b, calling _CallWindowProcAorW@24
0012d85c 7b07a7d4 (MethodDesc 0x7b4a7d78 +0x94 System.Windows.Forms.NativeWindow.DefWndProc(System.Windows.Forms.Message ByRef)), calling _CallWindowProcW@20
0012d888 7b07a7d4 (MethodDesc 0x7b4a7d78 +0x94 System.Windows.Forms.NativeWindow.DefWndProc(System.Windows.Forms.Message ByRef)), calling _CallWindowProcW@20
0012d894 79e8a67b ?Cleanup@CleanupWorkList@@QAGXH@Z+0x84, calling ?Collapse@StackingAllocator@@QAEXPAX@Z
0012d8b4 7b05ed83 (MethodDesc 0x7b4a56b0 +0x87 System.Windows.Forms.Form.DefWndProc(System.Windows.Forms.Message ByRef)), calling 7b64f510
0012d8fc 7b072faa (MethodDesc 0x7b5a5a50 +0x87a System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef))
0012d960 7b07f795 (MethodDesc 0x7b5a5588 +0x45 System.Windows.Forms.ScrollableControl.WndProc(System.Windows.Forms.Message ByRef)), calling (MethodDesc 0x7b5a5a50 +0 System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef))
0012d968 7b07f743 (MethodDesc 0x7b4a5910 +0x13 System.Windows.Forms.ContainerControl.WndProc(System.Windows.Forms.Message ByRef)), calling (MethodDesc 0x7b5a5588 +0 System.Windows.Forms.ScrollableControl.WndProc(System.Windows.Forms.Message ByRef))
0012d96c 7b063fc6 (MethodDesc 0x7b4a5550 +0x2b6 System.Windows.Forms.Form.WndProc(System.Windows.Forms.Message ByRef)), calling (MethodDesc 0x7b4a5910 +0 System.Windows.Forms.ContainerControl.WndProc(System.Windows.Forms.Message ByRef))
0012d97c 7b07a72d (MethodDesc 0x7b5a8168 +0xd System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef))
0012d980 7b07a706 (MethodDesc 0x7b5a8180 +0xd6 System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)), calling 0093704e
0012d994 7b08b845 (MethodDesc 0x7b4a7d70 +0x75 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr, Int32, IntPtr, IntPtr))
0012d9d4 79e88f63 _CallDescrWorker@20+0x33
0012d9f0 79e88ee4 _CallDescrWorkerWithHandler@24+0xa3, calling _CallDescrWorker@20
0012da58 7c802600 _WaitForSingleObjectEx@12+0xd8, calling __SEH_epilog
0012da70 79f2905b ?ForwardCallToManagedMethod@@YG_KPBEPA_KIHPAVMetaSig@@PAUArgumentRegisters@@PAXPAEIPAUUnmanagedToManagedCallGCInfo@@@Z+0x55, calling _CallDescrWorkerWithHandler@24
0012da90 79f29369 ?DoUMThunkCallWorker@@YG_JPAVThread@@PAVUMThkCallFrame@@PBVUMEntryThunk@@PAVUMThunkMarshInfo@@PAUUMThunkMLStub@@@Z+0x1e5, calling ?ForwardCallToManagedMethod@@YG_KPBEPA_KIHPAVMetaSig@@PAUArgumentRegisters@@PAXPAEIPAUUnmanagedToManagedCallGCInfo@@@Z
0012dafc 79f29249 ?DoUMThunkCallWorker@@YG_JPAVThread@@PAVUMThkCallFrame@@PBVUMEntryThunk@@PAVUMThunkMarshInfo@@PAUUMThunkMLStub@@@Z+0xc3, calling __alloca_probe_16
0012db98 79f29143 ?DoUMThunkCall@@YG_JPAVThread@@PAVUMThkCallFrame@@@Z+0x38b, calling ?DoUMThunkCallWorker@@YG_JPAVThread@@PAVUMThkCallFrame@@PBVUMEntryThunk@@PAVUMThunkMarshInfo@@PAUUMThunkMLStub@@@Z
0012dbc4 7c90da0c _NtReleaseMutant@8+0xc
0012dbc8 7c8024c7 _ReleaseMutex@4+0x10, calling _NtReleaseMutant@8
0012dbd8 7475577a ?Leave@CTimList@@QAEXXZ+0x1c, calling _ReleaseMutex@4
0012dbe0 74755d2a ?GetDWORD@CTimList@@AAEKKW4TIEnum@@@Z+0x7f, calling __SEH_epilog
0012dc24 79f75cc2 ?RareDisablePreemptiveGC@Thread@@QAEXXZ+0x3c6, calling _RtlRestoreLastWin32Error@4
0012dc5c 79fdfe26 _StubRareDisableTHROWWorker@8+0x5d, calling ?HandleThreadAbort@Thread@@QAEXH@Z
0012dc60 79fdfe35 _StubRareDisableTHROWWorker@8+0x6c, calling  (JitHelp: CORINFO_HELP_GET_THREAD)
0012dc70 003521f6 003521f6, calling ?DoUMThunkCall@@YG_JPAVThread@@PAVUMThkCallFrame@@@Z
0012dca0 7e418734 _InternalCallWinProc@20+0x28
0012dcc0 7e418734 _InternalCallWinProc@20+0x28
0012dcec 7e418816 _UserCallWinProcCheckWow@32+0x150, calling _InternalCallWinProc@20
0012dd54 7e428ea0 _DispatchClientMessage@20+0xa3, calling _UserCallWinProcCheckWow@32
0012dd84 7e42b317 _CallHookWithSEH@16+0x21
0012dda8 7e428eec ___fnDWORD@4+0x24
0012ddc0 7e4278d0 ___fnHkINLPMSG@4+0x25, calling _CallHookWithSEH@16
0012ddf4 7e4193e9 _NtUserPeekMessage@20+0xc
0012ddf8 7e4193a8 __PeekMessage@24+0x74, calling _NtUserPeekMessage@20
0012de20 7e419402 _PeekMessageW@20+0xbc, calling __PeekMessage@24
0012de4c 7755b2bc ?MyPeekMessage@CCliModalLoop@@QAEHPAUtagMSG@@PAUHWND__@@IIG@Z+0x30, calling _PeekMessageW@20
0012de94 7752f0f0 ?PeekRPCAndDDEMessage@CCliModalLoop@@AAEHXZ+0x30, calling ?MyPeekMessage@CCliModalLoop@@QAEHPAUtagMSG@@PAUHWND__@@IIG@Z
0012dec8 7755b2bc ?MyPeekMessage@CCliModalLoop@@QAEHPAUtagMSG@@PAUHWND__@@IIG@Z+0x30, calling _PeekMessageW@20
0012ded4 7752f1ef ?FindMessage@CCliModalLoop@@AAEHK@Z+0x2d, calling ?PeekRPCAndDDEMessage@CCliModalLoop@@AAEHXZ
0012dee0 7e4195f9 _RealMsgWaitForMultipleObjectsEx@20+0x13e, calling _WaitForMultipleObjectsEx@20
0012deec 7e4184ce _NtUserCallNoParam@4+0xc
0012def0 7e4184ba _NtUserCallOneParam@8+0xc
0012def4 7e42ae7a _RealGetQueueStatus@4+0x26, calling _NtUserCallOneParam@8
0012df04 7752f28f ?HandleWakeForMsg@CCliModalLoop@@AAEXXZ+0x3b, calling ?FindMessage@CCliModalLoop@@AAEHK@Z
0012df50 7752f23e ?BlockFn@CCliModalLoop@@QAEJPAPAXKPAK@Z+0x8b, calling ?HandleWakeForMsg@CCliModalLoop@@AAEXXZ
0012df64 77557237 _CoWaitForMultipleHandles@20+0xcf, calling ?BlockFn@CCliModalLoop@@QAEJPAPAXKPAK@Z
0012dfd8 79f27b88 ?NT5WaitRoutine@@YGKHKHPAPAXH@Z+0x51, calling _CoWaitForMultipleHandles@20
0012dff0 79f17565 ?GetFinalApartment@Thread@@QAE?AW4ApartmentState@1@XZ+0x8d, calling __EH_epilog3
0012dff8 79f27acf ?MsgWaitHelper@@YGKHPAPAXHKH@Z+0xa5, calling ?NT5WaitRoutine@@YGKHKHPAPAXH@Z
0012e04c 79f17565 ?GetFinalApartment@Thread@@QAE?AW4ApartmentState@1@XZ+0x8d, calling __EH_epilog3
0012e064 79f27a33 ?DoAppropriateAptStateWait@Thread@@AAEKHPAPAXHKW4WaitMode@@@Z+0x28, calling ?MsgWaitHelper@@YGKHPAPAXHKH@Z
0012e084 79f17493 ?DoAppropriateWaitWorker@Thread@@AAEKHPAPAXHKW4WaitMode@@@Z+0x144, calling ?DoAppropriateAptStateWait@Thread@@AAEKHPAPAXHKW4WaitMode@@@Z
0012e108 79f1732f ?DoAppropriateWait@Thread@@QAEKHPAPAXHKW4WaitMode@@PAUPendingSync@@@Z+0x40, calling ?DoAppropriateWaitWorker@Thread@@AAEKHPAPAXHKW4WaitMode@@@Z
0012e140 79ef5723 ?AcquireSafeHandle@@YGXPAPAVSafeHandle@@@Z+0x35, calling __EH_epilog3
0012e158 7a07b49c ?CorWaitOneNative@WaitHandleNative@@SIHPAVSafeHandle@@H_N1@Z+0x14e, calling ?DoAppropriateWait@Thread@@QAEKHPAPAXHKW4WaitMode@@PAUPendingSync@@@Z
0012e1b4 7a07b2dd ?CorWaitOneNative@WaitHandleNative@@SIHPAVSafeHandle@@H_N1@Z+0x21, calling @LazyMachStateCaptureState@4
0012e218 7a080550 ?Start@ThreadNative@@SIXPAVThreadBaseObject@@PAVObject@@PAW4StackCrawlMark@@@Z+0x1f, calling @LazyMachStateCaptureState@4
0012e25c 793d424e (MethodDesc 0x7924ad60 +0x2e System.Threading.WaitHandle.WaitOne(Int64, Boolean)), calling ?CorWaitOneNative@WaitHandleNative@@SIHPAVSafeHandle@@H_N1@Z
0012e274 793d4193 (MethodDesc 0x7924ad48 +0x23 System.Threading.WaitHandle.WaitOne(Int32, Boolean)), calling (MethodDesc 0x7924ad60 +0 System.Threading.WaitHandle.WaitOne(Int64, Boolean))
0012e288 793d420e (MethodDesc 0x7924ad58 +0xa System.Threading.WaitHandle.WaitOne())
>>>> 0012e290 012305e7 (MethodDesc 0x925928 +0x1cf DeadLockWaitOne.Form1.test(Int32))
0012e2d4 79e7bbb1 _PreStubWorker@4+0x138, calling __EH_epilog3
0012e2d8 00351f3e 00351f3e, calling _PreStubWorker@4
0012e310 79e88f63 _CallDescrWorker@20+0x33
0012e318 7c949a41 _RtlAllocateHeapSlowly@12+0xd7c, calling _RtlFillMemoryUlong@12
0012e320 79e88ee4 _CallDescrWorkerWithHandler@24+0xa3, calling _CallDescrWorker@20
0012e3a0 79e88e31 ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0x19c, calling _CallDescrWorkerWithHandler@24
0012e3d0 79e88fe3 ??0MetaSig@@QAE@PAV0@@Z+0x38, calling _memcpy
0012e3dc 79e88db3 ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0xaf, calling ?addition@?$ClrSafeInt@I@@SG_NIIAAI@Z
0012e3e8 79e88dc3 ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0xbb, calling __alloca_probe_16
0012e464 79e74753 ?Leave@CrstBase@@AAEXXZ+0x96, calling __EH_epilog3
0012e468 79e74ebd ?LazyInit@HelperMethodFrame@@IAEXPAXPAULazyMachState@@@Z+0x17, calling  (JitHelp: CORINFO_HELP_GET_THREAD)
0012e480 79e8a1af ??0HelperMethodFrame_1OBJ@@QAE@PAXPAULazyMachState@@IPAPAVObject@@@Z+0x14, calling ??0HelperMethodFrame@@QAE@PAXPAULazyMachState@@I@Z
0012e49c 79e88d3b ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0x1f, calling __alloca_probe_16
0012e4e0 79e88d19 ?CallTargetWorker@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KH@Z+0x20, calling ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z
0012e4f8 79e88cf6 ?Call@MethodDescCallSite@@QAEXPB_K@Z+0x18, calling ?CallTargetWorker@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KH@Z
0012e50c 7a11ae16 ?InvokeImpl@@YGPAVObject@@PAVMethodDesc@@PAV1@PAVPtrArray@@PAUSignatureNative@@KVTypeHandle@@@Z+0x43f, calling ?Call@MethodDescCallSite@@QAEXPB_K@Z
0012e528 7a11ac68 ?InvokeImpl@@YGPAVObject@@PAVMethodDesc@@PAV1@PAVPtrArray@@PAUSignatureNative@@KVTypeHandle@@@Z+0x28e, calling __alloca_probe_16
0012e5c4 79e7d329 ?GetTypeHandleThrowing@SigPointer@@QBE?AVTypeHandle@@PAVModule@@PBVSigTypeContext@@W4LoadTypesFlag@ClassLoader@@W4ClassLoadLevel@@HPBVSubstitution@@0@Z+0xe97, calling __EH_epilog3_GS
0012e5c8 79eec9b8 ?GetLastTypeHandleThrowing@MetaSig@@QBE?AVTypeHandle@@W4LoadTypesFlag@ClassLoader@@W4ClassLoadLevel@@H@Z+0x21, calling ?GetTypeHandleThrowing@SigPointer@@QBE?AVTypeHandle@@PAVModule@@PBVSigTypeContext@@W4LoadTypesFlag@ClassLoader@@W4ClassLoadLevel@@HPBVSubstitution@@0@Z
0012e6b4 79e74753 ?Leave@CrstBase@@AAEXXZ+0x96, calling __EH_epilog3
0012e6b8 79e74ebd ?LazyInit@HelperMethodFrame@@IAEXPAXPAULazyMachState@@@Z+0x17, calling  (JitHelp: CORINFO_HELP_GET_THREAD)
0012e6d0 79e8a1af ??0HelperMethodFrame_1OBJ@@QAE@PAXPAULazyMachState@@IPAPAVObject@@@Z+0x14, calling ??0HelperMethodFrame@@QAE@PAXPAULazyMachState@@I@Z
0012e6f4 7a11b0fa ?InvokeMethodFast@RuntimeMethodHandle@@SIPAVObject@@PAPAVMethodDesc@@PAV2@PAXKPAUSignatureNative@@PAVPtrArray@@@Z+0xbd, calling ?InvokeImpl@@YGPAVObject@@PAVMethodDesc@@PAV1@PAVPtrArray@@PAUSignatureNative@@KVTypeHandle@@@Z
0012e750 7a11b05e ?InvokeMethodFast@RuntimeMethodHandle@@SIPAVObject@@PAPAVMethodDesc@@PAV2@PAXKPAUSignatureNative@@PAVPtrArray@@@Z+0x24, calling @LazyMachStateCaptureState@4
0012e7b4 793cf629 (MethodDesc 0x79248640 +0x49 System.RuntimeMethodHandle.InvokeMethodFast(System.Object, System.Object[], System.Signature, System.Reflection.MethodAttributes, System.RuntimeTypeHandle)), calling ?InvokeMethodFast@RuntimeMethodHandle@@SIPAVObject@@PAPAVMethodDesc@@PAV2@PAXKPAUSignatureNative@@PAVPtrArray@@@Z
0012e800 794012bf (MethodDesc 0x79242888 +0x167 System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo, Boolean)), calling (MethodDesc 0x79248640 +0 System.RuntimeMethodHandle.InvokeMethodFast(System.Object, System.Object[], System.Signature, System.Reflection.MethodAttributes, System.RuntimeTypeHandle))
0012e838 793ac0fa (MethodDesc 0x7923bbd8 +0x5a System.Delegate.DynamicInvokeImpl(System.Object[])), calling (MethodDesc 0x79242888 +0 System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo, Boolean))
0012e860 7b06ec1d (MethodDesc 0x7b5a5f80 +0x9d System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry))
0012e864 79362186 (MethodDesc 0x7924b598 +0x3e System.Threading.SynchronizationContext.SetSynchronizationContext(System.Threading.SynchronizationContext)), calling (MethodDesc 0x7913f578 +0 System.Threading.SynchronizationContext.SetSynchronizationContext(System.Threading.SynchronizationContext, System.Threading.SynchronizationContext))
0012e884 7b06eca7 (MethodDesc 0x7b5a5f78 +0x6b System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(System.Object)), calling (MethodDesc 0x7b5a5f80 +0 System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry))
0012e8b0 793685af (MethodDesc 0x7913f3e0 +0x43 System.Threading.ExecutionContext.runTryCode(System.Object))
0012e8c0 79e88f63 _CallDescrWorker@20+0x33
0012e8d0 79e88ee4 _CallDescrWorkerWithHandler@24+0xa3, calling _CallDescrWorker@20
0012e950 79e88e31 ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0x19c, calling _CallDescrWorkerWithHandler@24
0012e980 79e88fe3 ??0MetaSig@@QAE@PAV0@@Z+0x38, calling _memcpy
0012e98c 79e88db3 ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0xaf, calling ?addition@?$ClrSafeInt@I@@SG_NIIAAI@Z
0012e998 79e88dc3 ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0xbb, calling __alloca_probe_16
0012e9f8 79e8a67b ?Cleanup@CleanupWorkList@@QAGXH@Z+0x84, calling ?Collapse@StackingAllocator@@QAEXPAX@Z
0012ea0c 79e8a69e ?Cleanup@CleanupWorkList@@QAGXH@Z+0x79d, calling @__security_check_cookie@4
0012ea10 7c80262a _WaitForSingleObjectEx@12+0xe5, calling _RtlDeactivateActivationContextUnsafeFast@4
0012ea4c 79e88d3b ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z+0x1f, calling __alloca_probe_16
0012ea90 79e88d19 ?CallTargetWorker@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KH@Z+0x20, calling ?CallDescr@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KHH@Z
0012eaa8 79e88cf6 ?Call@MethodDescCallSite@@QAEXPB_K@Z+0x18, calling ?CallTargetWorker@MethodDesc@@AAE_KPBEPAVMetaSig@@PB_KH@Z
0012eabc 79ef80d3 ?ExecuteCodeWithGuaranteedCleanupHelper@@YGXPAUECWGC_GC@@@Z+0xb2, calling ?Call@MethodDescCallSite@@QAEXPB_K@Z
0012eb84 79e88805 ?SizeOf@SigPointer@@QBEIPAVModule@@PBVSigTypeContext@@@Z+0x106, calling __EH_epilog3
0012eb88 79e816f7 ?GetReturnTypeSize@MetaSig@@QAEIXZ+0x17, calling ?SizeOf@SigPointer@@QBEIPAVModule@@PBVSigTypeContext@@@Z
0012eb90 79e88888 ?CalculateHasFPReturn@MetaSig@@QAEXXZ+0x8, calling ?GetReturnTypeNormalized@MetaSig@@QBE?AW4CorElementType@@XZ
0012eb98 79e88a0d ?ForceSigWalk@MetaSig@@QAEXH@Z+0x19d, calling ?CalculateHasFPReturn@MetaSig@@QAEXXZ
0012ec2c 79e8a67b ?Cleanup@CleanupWorkList@@QAGXH@Z+0x84, calling ?Collapse@StackingAllocator@@QAEXPAX@Z
0012ec40 79e8a69e ?Cleanup@CleanupWorkList@@QAGXH@Z+0x79d, calling @__security_check_cookie@4
0012ec44 7c80262a _WaitForSingleObjectEx@12+0xe5, calling _RtlDeactivateActivationContextUnsafeFast@4
0012ec88 79ef7fde ?ExecuteCodeWithGuaranteedCleanup@ReflectionInvocation@@SIXPAVObject@@00@Z+0xf9, calling ?ExecuteCodeWithGuaranteedCleanupHelper@@YGXPAUECWGC_GC@@@Z
0012ecd0 79ef7f1e ?ExecuteCodeWithGuaranteedCleanup@ReflectionInvocation@@SIXPAVObject@@00@Z+0x28, calling @LazyMachStateCaptureState@4
0012ed38 793684fb (MethodDesc 0x7913f3d8 +0xa7 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)), calling ?ExecuteCodeWithGuaranteedCleanup@ReflectionInvocation@@SIXPAVObject@@00@Z
0012ed50 793683ee (MethodDesc 0x7913f3d0 +0x92 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)), calling (MethodDesc 0x7913f3d8 +0 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))
0012ed68 7b06ed78 (MethodDesc 0x7b4a6450 +0x90 System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry)), calling (MethodDesc 0x7913f3d0 +0 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))
0012ed84 7b06ea6b (MethodDesc 0x7b5a5f88 +0xb3 System.Windows.Forms.Control.InvokeMarshaledCallbacks()), calling (MethodDesc 0x7b4a6450 +0 System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry))
0012edbc 7b072f30 (MethodDesc 0x7b5a5a50 +0x800 System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)), calling (MethodDesc 0x7b5a5f88 +0 System.Windows.Forms.Control.InvokeMarshaledCallbacks())
0012ee20 7b07f795 (MethodDesc 0x7b5a5588 +0x45 System.Windows.Forms.ScrollableControl.WndProc(System.Windows.Forms.Message ByRef)), calling (MethodDesc 0x7b5a5a50 +0 System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef))
0012ee28 7b07f743 (MethodDesc 0x7b4a5910 +0x13 System.Windows.Forms.ContainerControl.WndProc(System.Windows.Forms.Message ByRef)), calling (MethodDesc 0x7b5a5588 +0 System.Windows.Forms.ScrollableControl.WndProc(System.Windows.Forms.Message ByRef))
0012ee2c 7b063fc6 (MethodDesc 0x7b4a5550 +0x2b6 System.Windows.Forms.Form.WndProc(System.Windows.Forms.Message ByRef)), calling (MethodDesc 0x7b4a5910 +0 System.Windows.Forms.ContainerControl.WndProc(System.Windows.Forms.Message ByRef))
0012ee3c 7b07a72d (MethodDesc 0x7b5a8168 +0xd System.Windows.Forms.Control+ControlNativeWindow.OnMessage(System.Windows.Forms.Message ByRef))
0012ee40 7b07a706 (MethodDesc 0x7b5a8180 +0xd6 System.Windows.Forms.Control+ControlNativeWindow.WndProc(System.Windows.Forms.Message ByRef)), calling 0093704e
0012ee54 7b08b845 (MethodDesc 0x7b4a7d70 +0x75 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr, Int32, IntPtr, IntPtr))
0012ee94 79e88f63 _CallDescrWorker@20+0x33
0012eeb0 79e88ee4 _CallDescrWorkerWithHandler@24+0xa3, calling _CallDescrWorker@20
0012ef30 79f2905b ?ForwardCallToManagedMethod@@YG_KPBEPA_KIHPAVMetaSig@@PAUArgumentRegisters@@PAXPAEIPAUUnmanagedToManagedCallGCInfo@@@Z+0x55, calling _CallDescrWorkerWithHandler@24
0012ef50 79f29369 ?DoUMThunkCallWorker@@YG_JPAVThread@@PAVUMThkCallFrame@@PBVUMEntryThunk@@PAVUMThunkMarshInfo@@PAUUMThunkMLStub@@@Z+0x1e5, calling ?ForwardCallToManagedMethod@@YG_KPBEPA_KIHPAVMetaSig@@PAUArgumentRegisters@@PAXPAEIPAUUnmanagedToManagedCallGCInfo@@@Z
0012efb8 79f29249 ?DoUMThunkCallWorker@@YG_JPAVThread@@PAVUMThkCallFrame@@PBVUMEntryThunk@@PAVUMThunkMarshInfo@@PAUUMThunkMLStub@@@Z+0xc3, calling __alloca_probe_16
0012efe8 79e8b035 ?RunML@@YGPBEPBEPBXPAXQAEQAVCleanupWorkList@@@Z+0x1313, calling @__security_check_cookie@4
0012efec 79e89233 ?Collapse@StackingAllocator@@QAEXPAX@Z+0x1c, calling ?Clear@StackingAllocator@@AAEXPAUStackBlock@@@Z
0012f000 79e8a67b ?Cleanup@CleanupWorkList@@QAGXH@Z+0x84, calling ?Collapse@StackingAllocator@@QAEXPAX@Z
0012f054 79f29143 ?DoUMThunkCall@@YG_JPAVThread@@PAVUMThkCallFrame@@@Z+0x38b, calling ?DoUMThunkCallWorker@@YG_JPAVThread@@PAVUMThkCallFrame@@PBVUMEntryThunk@@PAVUMThunkMarshInfo@@PAUUMThunkMLStub@@@Z
0012f0e0 79f75cc2 ?RareDisablePreemptiveGC@Thread@@QAEXXZ+0x3c6, calling _RtlRestoreLastWin32Error@4
0012f118 79fdfe26 _StubRareDisableTHROWWorker@8+0x5d, calling ?HandleThreadAbort@Thread@@QAEXH@Z
0012f11c 79fdfe35 _StubRareDisableTHROWWorker@8+0x6c, calling  (JitHelp: CORINFO_HELP_GET_THREAD)
0012f12c 003521f6 003521f6, calling ?DoUMThunkCall@@YG_JPAVThread@@PAVUMThkCallFrame@@@Z
0012f15c 7e418734 _InternalCallWinProc@20+0x28
0012f17c 7e418734 _InternalCallWinProc@20+0x28
0012f1a8 7e418816 _UserCallWinProcCheckWow@32+0x150, calling _InternalCallWinProc@20
0012f210 7e4189cd _DispatchMessageWorker@8+0x306, calling _UserCallWinProcCheckWow@32
0012f270 7e418a10 _DispatchMessageW@4+0xf, calling _DispatchMessageWorker@8
0012f280 79ef064c _NDirectGenericStubReturnFromCall@0
0012f2a4 0091a0ef 0091a0ef, calling _NDirectGenericStubWorker@8
0012f2d0 7b084766 (MethodDesc 0x7b5adea8 +0x2ea System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32, Int32, Int32)), calling 7b64e3d4
0012f2f0 7b084766 (MethodDesc 0x7b5adea8 +0x2ea System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32, Int32, Int32)), calling 7b64e3d4
0012f308 7b08491c (MethodDesc 0x7b5adea8 +0x4a0 System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32, Int32, Int32)), calling _NtUserWaitMessage@0
0012f388 7b08432d (MethodDesc 0x7b5ab448 +0x17d System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)), calling 00937152
0012f3f8 7b08416b (MethodDesc 0x7b4a8770 +0x53 System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)), calling (MethodDesc 0x7b5ab448 +0 System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext))
0012f428 7b0c69fe (MethodDesc 0x7b4a7670 +0x2e System.Windows.Forms.Application.Run(System.Windows.Forms.Form)), calling 7b64f868
0012f43c 012300af (MethodDesc 0x923000 +0x3f DeadLockWaitOne.Program.Main(System.String[])), calling (MethodDesc 0x7b4a7670 +0 System.Windows.Forms.Application.Run(System.Windows.Forms.Form))
.... (more stack - i've cut the unmanaged stack up until the application.run)
Interesting.  I'll try to read this over lunch today.
I stand corrected.  It does exactly what you describe.  I'm sure you already deduced this but I gather it must go something like this:

Your worker thread does the invokes, queuing up messages for the pump.
The pump causes the first queued call to start.
It gets to the wait and must not check the pump if no messages have come in, but since the windows message happens it goes ahead with the next message (your call #2).
And now call #2 is chugging along before #1 exits the wait.

So the bottom line is how do you stop that behavior without modifying a bunch of your code?  Can you just change to MTA instead of STA?  It works as advertised, with no pumping (and of course an unresponsive gui).  It shouldn't matter unless you're doing COM.
Avatar of Agarici

ASKER

unfortunately my app is realy huge, it has multiple modules and some require this thread to be STA. i tried it and changing to MTA does not work for me... :(
Sorry, I can't think of an easy fix.  The only thing I can think of would be maybe the below, just in case you are desperate...

Global replace of System.Threading.AutoResetEvent declarations to reference your own class, and you write a class that does a different kind of wait.  Your class could sleep and periodically check a synchronized bool, which I don't believe runs the pump.
Avatar of Agarici

ASKER

i stopped looking for an easy fix long ago :)
so if you have any ideas they are welcomed

thanks,
A.
ASKER CERTIFIED SOLUTION
Avatar of mastoo
mastoo
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Agarici

ASKER

after investigating this for a while i found it to be a bug in .net
so, like MS said, no work-around, i should change the design.