SwitchToFiber

The SwitchToFiber function schedules a fiber. The caller of must be a fiber.

VOID SwitchToFiber(
  LPVOID lpFiber  // pointer to fiber to switch to
);
 

Parameters

lpFiber
Specifies the address of the fiber to switch to.

Return Values

This function does not return a value.

Remarks

You create fibers with CreateFiber. Before you can schedule fibers associated with a thread, you must call ConvertThreadToFiber to set up an area in which to save the fiber state information. The thread is now the currently executing fiber.

The SwitchToFiber function saves the state information of the current fiber and restores the state of the specified fiber. You can call SwitchToFiber with the address of a fiber created by a different thread. To do this, you must have the address returned to the other thread when it called CreateFiber and you must use proper synchronization.

Warning  Avoid making the following call:

SwitchToFiber( GetCurrentFiber() );
 

This call causes unpredictable problems.

QuickInfo

  Windows NT: Requires version 3.51 SP3 or later.
  Windows: Requires Windows 98 or later.
  Windows CE: Unsupported.
  Header: Declared in winbase.h.
  Import Library: Use kernel32.lib.

See Also

Processes and Threads Overview, Process and Thread Functions, CreateFiber, ConvertThreadToFiber