Table of Contents

Class UserEventLifetime

Namespace
Sdl3Sharp.Events
Assembly
Sdl3Sharp.dll

Represents the lifetime of a UserEvent, allowing to store managed data associated with it

public sealed class UserEventLifetime : IDisposable
Inheritance
UserEventLifetime
Implements
Inherited Members

Remarks

An UserEventLifetime allows to create UserEvents that are able to participate in SDL's event system, while still being able to store managed data in their Data1 and Data2 properties.

UserEventLifetimes restrict the lifetime of managed data associated with UserEvents created from them. Keep the UserEventLifetime instance alive as long as you need to access the managed data from the UserEvents created from it. Once you're sure that no more managed data access is needed, you can and should dispose the UserEventLifetime instance.

Constructors

UserEventLifetime()

Creates a new UserEventLifetime

public UserEventLifetime()

Properties

Data1

Gets or sets the value of the first managed user defined data slot, Data1, for UserEvents created from this UserEventLifetime

public object? Data1 { get; set; }

Property Value

object

The value of the first managed user defined data slot, Data1, for UserEvents created from this UserEventLifetime

Remarks

Setting the value of this property sets the value of the Data1 property for all UserEvents created from this UserEventLifetime, as long as they still retained their original RawData1 value.

Exceptions

ObjectDisposedException

The backing UserEventLifetime was already disposed

Data2

Gets or sets the value of the first managed user defined data slot, Data2, for UserEvents created from this UserEventLifetime

public object? Data2 { get; set; }

Property Value

object

The value of the first managed user defined data slot, Data2, for UserEvents created from this UserEventLifetime

Remarks

Setting the value of this property sets the value of the Data2 property for all UserEvents created from this UserEventLifetime, as long as they still retained their original RawData2 value.

Exceptions

ObjectDisposedException

The backing UserEventLifetime was already disposed

Methods

Dispose()

Diposes the UserEventLifetime

public void Dispose()

Remarks

After disposing the UserEventLifetime, all UserEvents created from it will no longer be able to access their managed data slots via the Data1 and Data2 properties.

~UserEventLifetime()

protected ~UserEventLifetime()

GetEvent(EventType, ulong, uint, int)

Gets a new UserEvent backed by this UserEventLifetime

public UserEvent GetEvent(EventType type, ulong timestamp, uint windowId, int code)

Parameters

type EventType

The type of the event. This will become the value of the resulting UserEvent's Type property.

timestamp ulong

The timestamp of the event. You can populate this from NanosecondTicks. This will become the value of the resulting UserEvent's Timestamp property.

windowId uint

The window Id of the Window associated with the event, or 0 if there is no associated window. This will become the value of the resulting UserEvent's WindowId property.

code int

The user defined event code. This will become the value of the resulting UserEvent's Code property.

Returns

UserEvent

A new UserEvent backed by this UserEventLifetime

Remarks

type must be a valid value for UserEvents. Otherwise, it will lead this method to throw an ArgumentException! Try registering user defined event type using TryRegister(out EventType) or TryRegister(Span<EventType>).

Exceptions

ArgumentException

type was not valid for UserEvents