SwitchToFiber function (winbase.h)

Schedules a fiber. The function must be called on a fiber.

Syntax

void SwitchToFiber(
  [in] LPVOID lpFiber
);

Parameters

[in] lpFiber

The address of the fiber to be scheduled.

Return value

None

Remarks

You create fibers with the CreateFiber function. 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.

Avoid making the following call:

SwitchToFiber( GetCurrentFiber() );

This call can cause unpredictable problems.

To compile an application that uses this function, define _WIN32_WINNT as 0x0400 or later. For more information, see Using the Windows Headers.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps | UWP apps]
Minimum supported server Windows Server 2003 [desktop apps | UWP apps]
Target Platform Windows
Header winbase.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See also

ConvertThreadToFiber

CreateFiber

Fibers

Process and Thread Functions