Signal
An owner/name signal pair with C# await support.
A C# struct storing an Owner object and a signal Name. Signal(owner, name) stores this pair; it does not declare a new signal on the object. Signal implements the await protocol through GetAwaiter(): waiting completes when the corresponding owner signal occurs.
For example, ProcessFrame belongs to EntityTree. Waiting requires a live owner and the exact EntityTree.SignalName.ProcessFrame name; default(Signal), with empty references, is not a ready-to-use awaitable.
Signal has no C# conversion to bool. An Owner alone does not establish signal existence or whether it has already been emitted. Use normal event subscriptions for handlers exposed as C# events.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
SignalConstructor
public Signal(ReckfellObject owner, StringName name);Stores owner and the name wrapper. Does not declare a signal, subscribe or buffer past emissions. Waiting requires a live owner and an existing signal; check dynamic names with owner.HasSignal(name). Stores the same StringName wrapper: do not dispose it before using the Signal.
| Name | Type | Default |
|---|---|---|
owner | ReckfellObject | — |
name | StringName | — |
ownerLive object exposing the signal; Signal does not own its native lifetime.
nameExact existing signal name, preferably a SignalName constant. This does not declare a new signal.
Properties2
NameProperty
public StringName Name { get; }Returns the stored signal-name wrapper. It neither verifies signal existence nor describes its latest emission. default(Signal) returns null. The name is borrowed; do not Dispose a shared SignalName constant or a wrapper still in use.
OwnerProperty
public ReckfellObject Owner { get; }Returns the stored owner reference. The reference does not guarantee the native object still exists; check ReckfellObject.IsInstanceValid when needed. default(Signal) returns null. Reading neither subscribes nor transfers object ownership.
Methods1
GetAwaiterIAwaiter<Variant[]>
public IAwaiter<Variant[]> GetAwaiter();Creates a new awaiter and immediately connects a one-shot handler for the next signal emission. C# calls this method for await signal. Another GetAwaiter creates an independent wait; past emissions are not replayed.
The result is an array of copied Variant arguments in signal declaration order. Dispose its elements after reading; a signal without arguments returns an empty array. WaitNextProcess in the example uses the built-in ProcessFrame and disposes the result.
using System.Threading.Tasks;
using Reckfell;
public static class CallableSignalExamples
{
public static int Twice(int value)
{
var callback = Callable.From<int, int>(static number => number * 2);
using var argument = Variant.From(value);
using var result = callback.Call(argument);
return result.AsInt32();
}
public static void SetLabelLater(Label label, string text)
{
var callback = Callable.From<string>(value =>
{
if (ReckfellObject.IsInstanceValid(label)) label.Text = value;
});
using var argument = Variant.From(text);
callback.CallDeferred(argument);
}
public static async Task WaitNextProcess(EntityTree tree)
{
Variant[] arguments = await new Signal(tree, EntityTree.SignalName.ProcessFrame);
foreach (var argument in arguments) argument.Dispose();
}
}There is no CancellationToken parameter or automatic completion when owner is freed: the wait can remain incomplete. Do not place required resource cleanup only after this await. For a repeated handler with controlled unsubscription, use ordinary C# += and -= events; see C# signals.
IAwaiter<Variant[]>New awaiter for the next emission, returning Variant[]. It does not establish a successful connection for an invalid name or provide automatic cancellation.