GameFiberSleepUntil Method

RAGE Plugin Hook Documentation

[This is preliminary documentation and is subject to change.]

Yields the executing fiber until the specified condition is met.

Namespace:  Rage
Assembly:  RagePluginHook (in RagePluginHook.dll) Version: 0.0.0.0 (0.56.1131.11510)
Syntax

public static void SleepUntil(
	Func<bool> condition,
	int timeOut
)

Parameters

condition
Type: SystemFuncBoolean
The condition.
timeOut
Type: SystemInt32
The maximum time to sleep. If set to 0, the call will not time out.
Examples

The following statement:

C#
GameFiber.SleepUntil(() => !vehicle || vehicle.Speed >= FiftyKilometersPerHour, 30000);

Is equivalent to the following piece of code:

C#
ulong startTime = Game.TickCount;
while (vehicle && vehicle.Speed < FiftyKilometersPerHour)
{
    if (Game.TickCount > startTime + 30000)
    {
        break;
    }

    GameFiber.Yield();
}
Examples

The following statement:

C#
GameFiber.SleepUntil(() => !vehicle || vehicle.Speed >= FiftyKilometersPerHour, 0);

Is equivalent to the following piece of code:

C#
while (vehicle && vehicle.Speed < FiftyKilometersPerHour)
{
    GameFiber.Yield();
}
See Also

Reference