title: C# Code hangs after Pinvoke SendMessage
body: <p>I am automating test procedures for a separate Windows Form application. I am currently using pinvoke to communicate with the other application. In this application, there is a button which creates a new pop up window when clicked. </p>
  
  <p>I am communicating with the buttons and fields successfully. However, when clicking the button the code following SendMessage() does not run. The button is clicked successfully and the window appears, but the following code is not ran until I manually close the window.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    [DllImport("user32.dll")]
      public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
  </code></pre>
  
  <p>.</p>
  
  <pre><code>    buttonHandle = FindWindowEx(parentHandle, new IntPtr(0), new IntPtr(0), windowTitle);
      SendMessage(childHandle, BM_CLICK, new IntPtr(0), "");
      MessageBox.Show("This won't show until I close the window");
  </code></pre>
  
  <p>Everything works fine, except whatever line of code comes after SendMessage() isn't ran until I close the new window created when the button is clicked.</p>
  
  <p>Can anyone help explain what may be going on here? </p>
  
  <p>Thanks!</p>