   Win32 Fibers
  According to the documentation you can use SwitchToFiber on a fiber fromanother thread, but then the thread I called SwitchToFiber in is nowsuspended. How do I resume that thread? What I really want to do is justswitch the running fiber in a thread from another thread.   
  to resume it you would call switchtofiber on the thread you want to switch to.  You manually do the switching with fibers:)CheersChris   ;  Moving fibers between threads?Be careful, here be dragons...   ;  Discredit the OP. My actual question is if there is any way what-so-ever to switch a fiber from another thread? Calling SwitchToFiber using a fiber in another thread will only run that thread's fiber in the calling thread. I need the original thread to run it as to preserve the APC queue and other components of the real thread.Note: Disgusting hacks are acceptable.   ;  The only way I know of for changing what a thread is doing is entirely platform dependant (meaning you will probably need one version for x86 and another for AMD64) and generally very ugly, but since you insist that disgusting hacks are acceptable://Acquire requried priveleges (Not needed for creator of threads)//Get required information:CONTEXT TheContext;SuspendThread(ThreadToChange);//Get WHOLE Context - CONTEXT_CONTROL | CONTEXT_INTEGER might be all you need, but it could be architecture specificTheContext.ContextFlags = CONTEXT_ALL;GetThreadContext(ThreadToChange, &TheContext);/*Architecture Dependant:First, allocate a small section of memory in the address space of ThreadToChange's parent process (ie your own if you spawned ThreadToChange), Probably using VirtualAllocMark the memory location as writable,then write to it the instructions to call SwitchToFiber with the arguments you want and then return (as if it were a function) - the Intel Instruction Set Manual would probably be helpful here (for the x86 version anyways), as would turning on the "Assembly Listing with Machine Code and Source Lines" in your compilerMark the memory as executable (and readable or whatever else is required to execute it)While thread is paused, add a few things to it's stack:1) the current execution point (in the manner needed for API calls to return, if they're special)2) Arguments required to free the just-allocated memory using VirtualFree (or or whatever function)3) the address of VirtualFree (in whatever format is requried by the code you put into the allocated memory)Finally, change the thread's current execution point (stored in the context) to point to the memory you allocated so execution will resume from there*/SetThreadContext(ThreadToChange, &TheContext);ResumeThread(ThreadToChange);At that point, the following sequence of events should occur in ThreadToChange:SwitchToFiber(...)Other fiber runs for however long and control gets back to the original fiberwhich immediately return into VirtualFreewhich gets it's arguments off the stack and cleans up the temporary memoryfinally, a return to the Original Execution Point(ThreadToChange is back to normal)   