# ICoroutine

Kind: Interface · Namespace: Sansar.Script · Assembly: Sansar.Script.dll · Script API 47.10.0

<div class="api-meta">
<span class="api-kind api-kind-interface" data-pagefind-filter="kind:Interface">Interface</span>
<span data-pagefind-filter="namespace:Sansar.Script">Namespace <a href="/scripting/api/sansar.script"><code>Sansar.Script</code></a></span>
</div>

<span id="T:Sansar.Script.ICoroutine"></span>

Token representing a coroutine.

```csharp
public interface ICoroutine
```

## Remarks

Manages an existing coroutine.

## Members at a glance

| Kind | Members |
|---|---|
| **Properties** | [IsAlive](#isalive) · [IsWaiting](#iswaiting) · [Name](#name) |
| **Methods** | [Abort](#abort) · [ResetSignals](#resetsignals) · [Signal](#signal) |

## Properties

### IsAlive

<div class="api-card">
<span id="P:Sansar.Script.ICoroutine.IsAlive"></span>

```csharp signature
public bool IsAlive { get; }
```

Is this coroutine is still working or waiting.

**Value:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — Will return false if this coroutine has completed or had Abort() called on it or thrown an exception.

</div>

### IsWaiting

<div class="api-card">
<span id="P:Sansar.Script.ICoroutine.IsWaiting"></span>

```csharp signature
public bool IsWaiting { get; }
```

Is the coroutine waiting.

**Value:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — True if the coroutine is waiting for time or an event.

</div>

### Name

<div class="api-card">
<span id="P:Sansar.Script.ICoroutine.Name"></span>

```csharp signature
public string Name { get; set; }
```

The name of the coroutine.

<details class="api-remarks"><summary>Remarks</summary>

By default the function name, but can be overwritten by anyone with the ICoroutine interface handle.

</details>

</div>


## Methods

### Abort

<div class="api-card">
<span id="M:Sansar.Script.ICoroutine.Abort"></span>
<span id="M:Sansar.Script.ICoroutine.Abort()"></span>

```csharp signature
public void Abort()
```

Stop the coroutine

<details class="api-remarks"><summary>Remarks</summary>

The coroutine will be deleted and will not run again.

</details>

</div>

### ResetSignals

<div class="api-card">
<span id="M:Sansar.Script.ICoroutine.ResetSignals"></span>
<span id="M:Sansar.Script.ICoroutine.ResetSignals()"></span>

```csharp signature
public void ResetSignals()
```

Reset the signal count on a coroutine.

<details class="api-remarks"><summary>Remarks</summary>

Will not re-sleep a coroutine that was waiting on signals.

</details>

</div>

### Signal

<div class="api-card">
<span id="M:Sansar.Script.ICoroutine.Signal"></span>
<span id="M:Sansar.Script.ICoroutine.Signal()"></span>

```csharp signature
public void Signal()
```

Send a signal to the coroutine and wake it up if it is waiting for a signal.

</div>


## Used in examples

- [AdvancedCoroutineExample.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/AdvancedCoroutineExample.cs)
- [ScriptLibrary/Scene/Light.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/Light.cs)
- [ScriptLibrary/Scene/LightOnOff.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/LightOnOff.cs)
- [ScriptLibrary/Scene/Sound.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/Sound.cs)
- [ScriptLibrary/Scene/TimeCountdown.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/TimeCountdown.cs)
- [ScriptLibrary/Scene/TimedEvents.cs](https://github.com/Wookey-Technologies/sansar-script-starter/blob/66af8b516b701088d043e4615acfcf5779356604/examples/official/ScriptLibrary/Scene/TimedEvents.cs)

<p class="api-generated" data-pagefind-ignore>Generated from the Sansar 47.10.0 client ScriptApi snapshot.</p>