title: How do I invoke a command in a Tcl thread asynchronously from a non-tcl thread?
body: <p>I'm doing some work in a C thread (I'm using pthreads) that is not associated with an Tcl interpreter. It possesses pointers to the ThreadId and TclInterp of an existing Tcl thread, and would like to send a script to this Tcl thread to be evaluated asynchronously. </p>
  
  <p>I can do it with <a href="http://wiki.tcl.tk/15342" rel="nofollow">XThreadUtil</a> synchronously and only if I block the Tcl thread until the C thread finishes execution. I really need the asynchronous behaviour. That is, the desired sequence of events is:</p>
  
  <ol>
  <li>tcl thread invokes command that spawns C thread and returns immediately;</li>
  <li>event loop of tcl thread resumes, C thread concurrently does its work;</li>
  <li>when C thread finishes work, it posts an event to the tcl thread's event queue and exits;</li>
  <li>tcl thread processes event when ready. </li>
  </ol>
  
  <p>I've tried using the Tcl thread notification API (Tcl_ThreadQueueEvent/Tcl_ThreadAlert), and the async API (Tcl_AsnycCreate/Tcl_AsyncMark) with not much luck. I haven't been able to find much in the way of examples. Any help is much appreciated.</p>