> 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.ksevent-2.md).

# Class ksEvent\<E, T>

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

Wraps a C# event for the delegate T to allow event references.

```csharp
public class ksEvent<E, T> : ksIEvent where E : ksEvent<E, T> where T : class
```

#### Type Parameters

`E`

The type of this instance.

`T`

Delegate type

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) ← [ksEvent\<E, T>](/reactor/api-reference/ks.reactor/ks.reactor.ksevent-2.md)

#### Implements

[ksIEvent](/reactor/api-reference/ks.reactor/ks.reactor.ksievent.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)

## Fields

### m\_handlers <a href="#ks_reactor_ksevent_2_m_handlers" id="ks_reactor_ksevent_2_m_handlers"></a>

```csharp
protected List<T> m_handlers
```

#### Field Value

[List](https://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)\<T>

## Properties

### Count <a href="#ks_reactor_ksevent_2_count" id="ks_reactor_ksevent_2_count"></a>

The number of registered event handlers.

```csharp
public int Count { get; }
```

#### Property Value

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### Execute <a href="#ks_reactor_ksevent_2_execute" id="ks_reactor_ksevent_2_execute"></a>

Gets a delegate that invokes all event handlers. Returns null if no handlers are register.

```csharp
public T Execute { get; }
```

#### Property Value

T

## Methods

### Add(T) <a href="#ks_reactor_ksevent_2_add__1" id="ks_reactor_ksevent_2_add__1"></a>

Adds an item to the event list.

```csharp
public virtual void Add(T item)
```

#### Parameters

`item` T

Item to add

### ForEach(ForEachCallback) <a href="#ks_reactor_ksevent_2_foreach_ks_reactor_ksevent__0__1__foreachcallback" id="ks_reactor_ksevent_2_foreach_ks_reactor_ksevent__0__1__foreachcallback"></a>

Iterate and invoke the callback on all items.

```csharp
public virtual void ForEach(ksEvent<E, T>.ForEachCallback callback)
```

#### Parameters

`callback` [ksEvent](/reactor/api-reference/ks.reactor/ks.reactor.ksevent-2.md)\<E, T>.[ForEachCallback](/reactor/api-reference/ks.reactor/ks.reactor.ksevent-2/ks.reactor.ksevent-2.foreachcallback.md)

### ForEach(ForEachCancellableCallback) <a href="#ks_reactor_ksevent_2_foreach_ks_reactor_ksevent__0__1__foreachcancellablecallback" id="ks_reactor_ksevent_2_foreach_ks_reactor_ksevent__0__1__foreachcancellablecallback"></a>

Iterate and invoke the callback on all items.

```csharp
public virtual bool ForEach(ksEvent<E, T>.ForEachCancellableCallback callback)
```

#### Parameters

`callback` [ksEvent](/reactor/api-reference/ks.reactor/ks.reactor.ksevent-2.md)\<E, T>.[ForEachCancellableCallback](/reactor/api-reference/ks.reactor/ks.reactor.ksevent-2/ks.reactor.ksevent-2.foreachcancellablecallback.md)

Callback to call on the items. Iteration will stop if it returns false.

#### Returns

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

False if iteration was cancelled because the callback returned false.

### Remove(T) <a href="#ks_reactor_ksevent_2_remove__1" id="ks_reactor_ksevent_2_remove__1"></a>

Remove an item from the event list.

```csharp
public virtual void Remove(T item)
```

#### Parameters

`item` T

Item to be removed

## Operators

### operator +(ksEvent\<E, T>, T) <a href="#ks_reactor_ksevent_2_op_addition_ks_reactor_ksevent__0__1___1" id="ks_reactor_ksevent_2_op_addition_ks_reactor_ksevent__0__1___1"></a>

Adds an event handler to the event.

```csharp
public static E operator +(ksEvent<E, T> lhs, T rhs)
```

#### Parameters

`lhs` [ksEvent](/reactor/api-reference/ks.reactor/ks.reactor.ksevent-2.md)\<E, T>

Event to add handler to.

`rhs` T

Handler to add.

#### Returns

E

lhs

### operator -(ksEvent\<E, T>, T) <a href="#ks_reactor_ksevent_2_op_subtraction_ks_reactor_ksevent__0__1___1" id="ks_reactor_ksevent_2_op_subtraction_ks_reactor_ksevent__0__1___1"></a>

Adds an event handler to the event.

```csharp
public static E operator -(ksEvent<E, T> lhs, T rhs)
```

#### Parameters

`lhs` [ksEvent](/reactor/api-reference/ks.reactor/ks.reactor.ksevent-2.md)\<E, T>

Event to add handler to.

`rhs` T

Handler to add.

#### Returns

E

lhs
