title: Different behaviour in std::async between Visual Studio 2013 and 2015
body: <p>I'm using <code>std::async</code> in an app where I want to run a function asynchronously, and from that function use <code>SendMessage</code> function to talk to the UI from the worker thread. The following is an extract from an MFC test app that demonstrates what I'm doing:</p>
  
  <pre><code>LRESULT CStdAsyncProjDlg::OnUserPlusOne(WPARAM, LPARAM)
  {
      MessageBox("Message", "Hello World Again", MB_OK);
  
      return 0;
  }
  
  // Function that contains the async work.
  void TestAsync(HWND hDlg)
  {
      // Send a message to the UI from this worker. The WM_USER + 1 message
      // handler is CStdAsyncProjDlg::OnUserPlusOne
      SendMessage(hDlg, WM_USER + 1, 0, 0);
  }
  
  // This event is fired when a button is pressed on the MFC dialog.
  void CStdAsyncProjDlg::OnBnClickedButton1()
  {
      MessageBox("Message", "Hello World", MB_OK);
      std::async(std::launch::async, TestAsync, m_hWnd);
  }
  </code></pre>
  
  <p>In Visual Studio 2013 the above code works as expected. When I press the button I get a message box that says "Hello World", and once I click OK on that message box I get the other message box that says "Hello World Again".</p>
  
  <p>The issue I'm facing is once I migrate the above code to Visual Studio 2015 compiler, the app hangs after the <code>SendMessage</code> function call.</p>
  
  <p>Reading online (answer to <a href="https://stackoverflow.com/questions/18143661/what-is-the-difference-between-packaged-task-and-async">this question</a>) it mentions that the destructor for <code>std::future</code> blocks. I've changed the code in Visual Studio 2015 to store the returned <code>std::future</code> from <code>std::async</code> and that seems to fix the issue (the app doesn't hang and I get the second message box). However looking at the <code>std::future</code> code I can't seem to see anything different between Visual Studio 2013 and 2015. So my question is has anything changed in the way <code>std::async</code> works that would cause such behaviour?</p>
  
  <p>Thanks</p>