title: DirectX drawing in other thread
body: <p>I have some directx code that I want to run in second thread.
  I read the following <a href="http://www.codermind.com/answers/How-do-I-run-with-a-multithreaded-device-in-Direct3D9.html" rel="nofollow">How do I run with a multithreaded device in Direct3D9 ? </a> which says that is ok to use directx device from other thread as long as you are not using concurrently from many threads, and I am not doing that. And that you have to call CreateDevice and CreateWindow from the same thread , and some others functions like TestCooperativeLevel, Reset etc</p>
  
  <p>And I am doing the following :</p>
  
  <ol>
  <li><p>Create window and directx device in main thread;</p></li>
  <li><p>Start second thread and do the rendering and updating there , basically :</p>
  
  <ul>
  <li>update,</li>
  <li>BeginScene,</li>
  <li>Draw,</li>
  <li>EndScene,</li>
  <li>Present;</li>
  </ul></li>
  <li><p>Also I care to call TestCooperativeLevel, Reset, pDevice->Release and pDirect3D->Release() from the main thread.</p></li>
  </ol>
  
  <h3>The problem</h3>
  
  <p>The code is working when I test it in debug mode. But it doesn't in relase mode i.e it seems that the rendering threads draws all fine, but my main thread seems blocked and doesn't process messages, or maybe sometimes process them very slow. If just comment the call to Present , everything is fine ( of course it doesnot draw on screen ) i.e the main thread is responsive and second thread is running too. Sooo, is there some problem when calling Present from other thread, if the window and device is created in main thread ? As I read the following <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb147224%28v=vs.85%29.aspx" rel="nofollow">Multithreading Issues</a> such restriction has only on CreateDevice,TestCooperativeLevel and Release. </p>