title: new in one thread and delete in another, not allowed?
body: <p>Im reading data from a com-port. Since I don't know when data is coming, I'm reading continuously in a thread.</p>
  
  <p>When i have read enough bytes, I let the main thread know this by posting a message with a pointer to the string:</p>
  
  <pre><code>msg[i] = '\0';
  completeMsg = new char[i];
  strcpy(completeMsg, msg);
  PostMessage(hDlg, BT_MSG, NULL, (LPARAM) completeMsg);
  i = 0;
  </code></pre>
  
  <p>The main thread's response to this message is:</p>
  
  <pre><code>case BT_MSG:
  {
      char* msg = (char*) lParam;
      ShowMsg(msg);
      delete [] msg;
      break;
  }
  </code></pre>
  
  <p>But it looks like deleting in this thread isn't allowed because i get this error when I step the delete-line:</p>
  
  <blockquote>
    <p>Windows has triggered a breakpoint in
    SPO.exe.</p>
    
    <p>This may be due to a corruption of the
    heap, which indicates a bug in SPO.exe
    or any of the DLLs it has loaded.</p>
    
    <p>This may also be due to the user
    pressing F12 while SPO.exe has focus.</p>
    
    <p>The output window may have more
    diagnostic information.</p>
  </blockquote>
  
  <p>Should i use some global variable or send a message back to let the read-thread handle the deletion? It doesn't have a message-loop atm so I'd rather not add one just for this.</p>