title: C++/CLI ref class using a win32 thread
body: <p>I'm trying to encapsulate some older win32 code in a C++/CLI ref class to make it better accessible from .NET code. This class needs to start a Win32 thread and pass a pointer to the class as a thread parameter. The code looks something like this:</p>
  
  <pre><code>ref class MmePlayer
  {
      int StartPlayback()
      {
          hPlayThread = CreateThread(NULL, 0, PlayThread, this, 0, &amp;PlayThreadId);
      }
  };
  
  static DWORD WINAPI PlayThread(LPVOID pThreadParam)
  {
      // Get a pointer to the object that started the thread
      MmePlayer^ Me = pThreadParam;
  }
  </code></pre>
  
  <p>The thread really needs to be a Win32 thread because it receives messages from the MME subsystem. I've tried wrapping the PlayThread function pointer in an interior_ptr, but the compiler wouldn't allow that.
  Also, I've tried to make the thread function a class method, but the compiler does not allow the _stdcall modifier on ref class methods.
  Do you know of a way to handle this?  </p>