title: PlaySound in a different thread
body: <p>I am trying to develope a pc game with ships. I have a function <code>fire()</code></p>
  
  <pre><code>void Sprite::fire()
  {
      PlaySound("Sounds/azafire.wav", NULL, SND_FILENAME);//SND_FILENAME SND_SYNC
  
  }
  </code></pre>
  
  <p>witch just play a sound but when I call this function then all program frizing and when sound fish then program continue. </p>
  
  <p>My code were I call <code>fire</code> function show bellow </p>
  
  <pre><code>LRESULT CALLBACK 
  WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  {   
      Circle bc; // Not needed in this demo, leave default.
      Vec2   p0(gClientCenter);
      Vec2   v0(0.0f, 0.0f);
  
      switch( msg )
      {   
      // Create application resources.
      case WM_CREATE:
  
          // Create the sprites
          gBackground = new Sprite(ghAppInst,
              IDB_BACKGROUND1024X768, IDB_BACKGROUND1024X768MASK, bc, p0, v0);
  
          gF15 = new Sprite(ghAppInst, IDB_F15, IDB_F15MASK,
              bc, p0, v0);
  
          p0.x = 100;
          p0.y = 100;
          gF18 = new Sprite(ghAppInst, IDB_F18, IDB_F18MASK,
              bc, p0, v0);
          gF18-&gt;mDirection = -1;
  
          p0.x = 600;
          p0.y = 100;
          gF117 = new Sprite(ghAppInst, IDB_F117, IDB_F117MASK,
              bc, p0, v0);
          //Start move
          gF117-&gt;mDirection = 1;
  
          p0.x = 0.0f;
          p0.y = 0.0f;
          gBullet = new Sprite(ghAppInst, IDB_BULLET, IDB_BULLETMASK,
              bc, p0, v0);
  
          //Enemy Bullet
          p0.x = 0.0f;
          p0.y = 0.0f;
          gEnemyBullet = new Sprite(ghAppInst, IDB_ENEMYBULLET, IDB_ENEMYBULLETMASK,
              bc, p0, v0);
  
  
          // Create system memory DCs 
          ghSpriteDC = CreateCompatibleDC(0);
  
          // Create the backbuffer.
          gBackBuffer = new BackBuffer(
              hWnd, 
              gClientWidth,
              gClientHeight);
  
          return 0;
  
      case WM_COMMAND:
          switch(LOWORD(wParam))
          {
          // Destroy the window when the user selects the 'exit'
          // menu item.
          case ID_FILE_EXIT:
              DestroyWindow(ghMainWnd);
              break;
          }
          return 0;
  
      case WM_KEYDOWN:
          switch(wParam)
          {
          // Accelerate left.
          case 'A':
              gF15-&gt;mVelocity.x -= 5.0f;
              break;
          // Accelerate right.
          case 'D':
              gF15-&gt;mVelocity.x += 5.0f;
              break;
          // Accelerate up (remember +y goes down and -y goes up)
          case 'W':
              gF15-&gt;mVelocity.y -= 5.0f;
              break;
          // Accelerate down.
          case 'S':
              gF15-&gt;mVelocity.y += 5.0f;
              break;
          case VK_SPACE:
              // Add a bullet to the bullet list.
              gBulletPos.push_back(gF15-&gt;mPosition);
                      gF15-&gt;fire(); // !!!! Here is the problem !!!!
              break;
          case VK_LEFT:
              //Add LEFT ARROW key (0x25)
              gF15-&gt;mVelocity.x -= 5.0f;
              break;
          case VK_RIGHT:
              //Add Right ARROW Key 
              gF15-&gt;mVelocity.x += 5.0f;
              break;
          case VK_UP:
              //Add UP ARROW Key (0x26)
              gF15-&gt;mVelocity.y -= 5.0f;
              break;
          case VK_DOWN:
              //Add DOWN ARROW Key (0x28)
              gF15-&gt;mVelocity.y += 5.0f;
              break;
  
          }
          return 0;
      case WM_LBUTTONDOWN:
          //Add Left mouse button
          gBulletPos.push_back(gF15-&gt;mPosition);
          gF15-&gt;fire(); // !!!! Here is the problem !!!!
          return 0;
      case WM_RBUTTONDOWN:
          //Add Right mouse button
          gEnemyBulletPos.push_back(gF117-&gt;mPosition);
          return 0;
      // Destroy application resources.
      case WM_DESTROY:    
          delete gBackground;
          delete gF15;
          delete gF18;
          delete gF117;
          delete gBullet;
          delete gBackBuffer;
          DeleteDC(ghSpriteDC);
          PostQuitMessage(0); 
          return 0;   
      }   
      // Forward any other messages we didn't handle to the
      // default window procedure.
      return DefWindowProc(hWnd, msg, wParam, lParam);
  }
  </code></pre>
  
  <p>Can anyone help me? Thank you</p>