# ScriptHandle

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

<div class="api-meta">
<span class="api-kind api-kind-class" data-pagefind-filter="kind:Class">Class</span>
<span data-pagefind-filter="namespace:Sansar.Script">Namespace <a href="/scripting/api/sansar.script"><code>Sansar.Script</code></a></span>
<span>Inherits <a href="https://learn.microsoft.com/dotnet/api/system.idisposable">IDisposable</a></span>
</div>

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

A running script in Sansar.

```csharp
public class ScriptHandle : IDisposable
```

## Remarks

This is a lightweight handle which is used by some API methods to refer to a script.

## Members at a glance

| Kind | Members |
|---|---|
| **Properties** | [ID](#id) · [UnhandledExceptionRecoverable](#unhandledexceptionrecoverable) |
| **Methods** | [Dispose](#dispose) |
| **Events** | [UnhandledException](#unhandledexception) |

## Properties

### ID

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

```csharp signature
public ScriptId ID { get; }
```

The Sansar Script&#39;s unique ID. This ID is unique among all scripts currently running in a scene. It will change every time the script or scene is started.

**Value:** [ScriptId](/scripting/api/sansar.script/scriptid) — Returns [`ScriptId.Invalid`](/scripting/api/sansar.script/scriptid#invalid)  if the ScriptHandle is not initialized with a valid script.

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

Internal.

</details>

</div>

### UnhandledExceptionRecoverable

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

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

If true a script can keep running if an unhandled exception is processed by [`ScriptHandle.UnhandledException`](/scripting/api/sansar.script/scripthandle#unhandledexception).

**Value:** [bool](https://learn.microsoft.com/dotnet/api/system.boolean) — Boolean indicating if the script may continue running after an unhandled exception occurs.

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

If this is true and the [`ScriptHandle.UnhandledException`](/scripting/api/sansar.script/scripthandle#unhandledexception) event is set and does not throw and exception the script will continue to be scheduled.

</details>

</div>


## Methods

### Dispose

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

```csharp signature
public void Dispose()
```

Internal use only

</div>


## Events

### UnhandledException

<div class="api-card">
<span id="E:Sansar.Script.ScriptHandle.UnhandledException"></span>

```csharp signature
public event Action<object, Exception> UnhandledException
```

Run by the script scheduler when the invocation of a script event handler or coroutine throws an exception.

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

If [`ScriptHandle.UnhandledExceptionRecoverable`](/scripting/api/sansar.script/scripthandle#unhandledexceptionrecoverable) is true then the script may continue running if the handler does not throw an exception. If the handler needs to stop execution of the script it should throw the passed exception. The first argument is either the [`EventData`](/scripting/api/sansar.script/eventdata) that was being processed, or the Coroutine that was running when the exception occurred.

</details>

</div>




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