> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.reactor/ks.reactor.kscoroutinemanager.md).

# Class ksCoroutineManager

Namespace: [KS.Reactor](/reactor/api-reference/ks.reactor.md)\
Assembly: KSCommon.dll

Store and manage advancement of coroutines.

Predefined Coroutines Sleep Wait

```csharp
public class ksCoroutineManager
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) ← [ksCoroutineManager](/reactor/api-reference/ks.reactor/ks.reactor.kscoroutinemanager.md)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Constructors

### ksCoroutineManager() <a href="#ks_reactor_kscoroutinemanager__ctor" id="ks_reactor_kscoroutinemanager__ctor"></a>

Constructor.

```csharp
public ksCoroutineManager()
```

## Methods

### ForEach(CoroutineCallback) <a href="#ks_reactor_kscoroutinemanager_foreach_ks_reactor_kscoroutinemanager_coroutinecallback" id="ks_reactor_kscoroutinemanager_foreach_ks_reactor_kscoroutinemanager_coroutinecallback"></a>

Makes a callback for each coroutine. If the callback returns false, removes the coroutine.

```csharp
public void ForEach(ksCoroutineManager.CoroutineCallback coroutineCallback)
```

#### Parameters

`coroutineCallback` [ksCoroutineManager](/reactor/api-reference/ks.reactor/ks.reactor.kscoroutinemanager.md).[CoroutineCallback](/reactor/api-reference/ks.reactor/ks.reactor.kscoroutinemanager/ks.reactor.kscoroutinemanager.coroutinecallback.md)

### Kill() <a href="#ks_reactor_kscoroutinemanager_kill" id="ks_reactor_kscoroutinemanager_kill"></a>

Kills all of the coroutines.

```csharp
public void Kill()
```

### Pause() <a href="#ks_reactor_kscoroutinemanager_pause" id="ks_reactor_kscoroutinemanager_pause"></a>

Stops all coroutines. Warning: This will override all existing coroutine pause states.

```csharp
public void Pause()
```

### Resume() <a href="#ks_reactor_kscoroutinemanager_resume" id="ks_reactor_kscoroutinemanager_resume"></a>

Resumes all coroutines. Warning: This will override all existing coroutine pause states.

```csharp
public void Resume()
```

### Sleep(float, bool) <a href="#ks_reactor_kscoroutinemanager_sleep_system_single_system_boolean" id="ks_reactor_kscoroutinemanager_sleep_system_single_system_boolean"></a>

Waits for a period of time.

```csharp
public IEnumerator Sleep(float time, bool sleepRealTime = false)
```

#### Parameters

`time` [float](https://learn.microsoft.com/dotnet/api/system.single)

Time in seconds.

`sleepRealTime` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

Should the sleep time be tracked in real time

#### Returns

[IEnumerator](https://learn.microsoft.com/dotnet/api/system.collections.ienumerator)

IEnumerator

### Start(IEnumerator) <a href="#ks_reactor_kscoroutinemanager_start_system_collections_ienumerator" id="ks_reactor_kscoroutinemanager_start_system_collections_ienumerator"></a>

Creates a new coroutine from an IEnumerator function.

```csharp
public ksCoroutine Start(IEnumerator routine)
```

#### Parameters

`routine` [IEnumerator](https://learn.microsoft.com/dotnet/api/system.collections.ienumerator)

Function that will be processed once per frame.

#### Returns

[ksCoroutine](/reactor/api-reference/ks.reactor/ks.reactor.kscoroutine.md)

ksCoroutine

### UpdateCoroutines(float, float) <a href="#ks_reactor_kscoroutinemanager_updatecoroutines_system_single_system_single" id="ks_reactor_kscoroutinemanager_updatecoroutines_system_single_system_single"></a>

Advances all managed coroutines.

```csharp
public void UpdateCoroutines(float deltaTime, float realDeltaTime)
```

#### Parameters

`deltaTime` [float](https://learn.microsoft.com/dotnet/api/system.single)

Simulated delta time in seconds since the last update.

`realDeltaTime` [float](https://learn.microsoft.com/dotnet/api/system.single)

Real delta time in seconds since the last update.

### Wait(float, WaitCallback, bool) <a href="#ks_reactor_kscoroutinemanager_wait_system_single_ks_reactor_kscoroutinemanager_waitcallback_system_b" id="ks_reactor_kscoroutinemanager_wait_system_single_ks_reactor_kscoroutinemanager_waitcallback_system_b"></a>

Waits until `callback` returns true up to a maximum period of time.

```csharp
public IEnumerator Wait(float timeout, ksCoroutineManager.WaitCallback callback, bool realTime = false)
```

#### Parameters

`timeout` [float](https://learn.microsoft.com/dotnet/api/system.single)

Max time in seconds to wait.

`callback` [ksCoroutineManager](/reactor/api-reference/ks.reactor/ks.reactor.kscoroutinemanager.md).[WaitCallback](/reactor/api-reference/ks.reactor/ks.reactor.kscoroutinemanager/ks.reactor.kscoroutinemanager.waitcallback.md)

Callback to call every frame until it returns true or until the `timeout` is reached.

`realTime` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

Should the timeout be tracked in real time?

#### Returns

[IEnumerator](https://learn.microsoft.com/dotnet/api/system.collections.ienumerator)

IEnumerator
