> 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.kscoroutine.md).

# Class ksCoroutine

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

Wrapper for an IEnumerator function. Each update frame, KSCoroutines started on a script will advance to the next return yield statement.

```csharp
public class ksCoroutine
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) ← [ksCoroutine](/reactor/api-reference/ks.reactor/ks.reactor.kscoroutine.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

### ksCoroutine(IEnumerator) <a href="#ks_reactor_kscoroutine__ctor_system_collections_ienumerator" id="ks_reactor_kscoroutine__ctor_system_collections_ienumerator"></a>

Constructor.

```csharp
public ksCoroutine(IEnumerator func)
```

#### Parameters

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

Coroutine function.

## Properties

### IsComplete <a href="#ks_reactor_kscoroutine_iscomplete" id="ks_reactor_kscoroutine_iscomplete"></a>

Returns true if the coroutine is complete.

```csharp
public bool IsComplete { get; }
```

#### Property Value

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

### IsPaused <a href="#ks_reactor_kscoroutine_ispaused" id="ks_reactor_kscoroutine_ispaused"></a>

Returns the paused state of this coroutine.

```csharp
public bool IsPaused { get; }
```

#### Property Value

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

## Methods

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

Stops and destroy this coroutine.

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

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

Pauses processing of the coroutine.

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

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

Resumes processing of the coroutine.

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

### RunToEnd() <a href="#ks_reactor_kscoroutine_runtoend" id="ks_reactor_kscoroutine_runtoend"></a>

Repeatedly calls the coroutine until it is complete.

```csharp
public void RunToEnd()
```

### Step() <a href="#ks_reactor_kscoroutine_step" id="ks_reactor_kscoroutine_step"></a>

Checks the coroutine stack, and process the top element.

```csharp
public bool Step()
```

#### Returns

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

True if there is more work to do next frame, otherwise false.
