Interface IEvent<TEventArgs>
Represents an event which can be subscribed both synchronously or asynchorously, and is invoked asynchronously. An event is a notification for something that has happened. Interested parties can subscribe to the event and be notified when it triggers (https://en.wikipedia.org/wiki/Event-driven_programming).
Inherited Members
Namespace: AGS.API
Assembly: AGS.API.dll
Syntax
public interface IEvent<TEventArgs> : IDisposable
Type Parameters
Name | Description |
---|---|
TEventArgs |
Properties
| Improve this Doc View SourceSubscribersCount
Gets the number of subscribers to the event.
Declaration
int SubscribersCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 | The subscribers count. |
Methods
| Improve this Doc View SourceInvokeAsync(TEventArgs)
Invoke the event asynchronously.
Declaration
Task InvokeAsync(TEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
TEventArgs | args | Event arguments which can be used to provide additional data. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Subscribe(Action, CallbackPriority)
Subscribe the specified callback to the event. Once subscribed, whenever the event happens this callback will be called. This version of Subscribe ignores incoming arguments from the event (if you need the arguments, use the other overload which gets an action of TEventArgs).
Declaration
void Subscribe(Action callback, CallbackPriority priority = CallbackPriority.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Action | callback | Callback. |
CallbackPriority | priority | The callback priority (determines the order in which the subscribers get the events). |
Subscribe(Action<TEventArgs>, CallbackPriority)
Subscribe the specified callback to the event. Once subscribed, whenever the event happens this callback will be called.
Declaration
void Subscribe(Action<TEventArgs> callback, CallbackPriority priority = CallbackPriority.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Action<TEventArgs> | callback | Callback. |
CallbackPriority | priority | The callback priority (determines the order in which the subscribers get the events). |
SubscribeToAsync(Func<TEventArgs, Task>, CallbackPriority)
Subscribe the specified asynchronous callback to the event. Once subscribed, whenever the event happens this callback will be called.
Declaration
void SubscribeToAsync(Func<TEventArgs, Task> callback, CallbackPriority priority = CallbackPriority.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TEventArgs, System.Threading.Tasks.Task> | callback | Callback. |
CallbackPriority | priority | The callback priority (determines the order in which the subscribers get the events). |
SubscribeToAsync(Func<Task>, CallbackPriority)
Subscribe the specified asynchronous callback to the event. Once subscribed, whenever the event happens this callback will be called. This version of Subscribe ignores incoming arguments from the event (if you need the arguments, use the other overload which gets a func of TEventArgs -> Task).
Declaration
void SubscribeToAsync(Func<Task> callback, CallbackPriority priority = CallbackPriority.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Threading.Tasks.Task> | callback | Callback. |
CallbackPriority | priority | The callback priority (determines the order in which the subscribers get the events). |
Unsubscribe(Action, CallbackPriority)
Unsubscribe the specified callback from the event. This will stops notifications to call this callback.
Declaration
void Unsubscribe(Action callback, CallbackPriority priority = CallbackPriority.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Action | callback | Callback. |
CallbackPriority | priority | The callback priority (determines the order in which the subscribers get the events). |
Unsubscribe(Action<TEventArgs>, CallbackPriority)
Unsubscribe the specified callback from the event. This will stops notifications to call this callback.
Declaration
void Unsubscribe(Action<TEventArgs> callback, CallbackPriority priority = CallbackPriority.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Action<TEventArgs> | callback | Callback. |
CallbackPriority | priority | The callback priority (determines the order in which the subscribers get the events). |
UnsubscribeToAsync(Func<TEventArgs, Task>, CallbackPriority)
Unsubscribe the specified asynchronous callback from the event. This will stops notifications to call this callback.
Declaration
void UnsubscribeToAsync(Func<TEventArgs, Task> callback, CallbackPriority priority = CallbackPriority.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Func<TEventArgs, System.Threading.Tasks.Task> | callback | Callback. |
CallbackPriority | priority | The callback priority (determines the order in which the subscribers get the events). |
UnsubscribeToAsync(Func<Task>, CallbackPriority)
Unsubscribe the specified asynchronous callback from the event. This will stops notifications to call this callback.
Declaration
void UnsubscribeToAsync(Func<Task> callback, CallbackPriority priority = CallbackPriority.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Threading.Tasks.Task> | callback | Callback. |
CallbackPriority | priority | The callback priority (determines the order in which the subscribers get the events). |
WaitUntilAsync(Predicate<TEventArgs>, CallbackPriority)
Asynchronously wait until the event fires and the specific condition applies.
Declaration
Task WaitUntilAsync(Predicate<TEventArgs> condition, CallbackPriority priority = CallbackPriority.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Predicate<TEventArgs> | condition | The condition we are waiting to apply before moving on. |
CallbackPriority | priority | The callback priority (determines the order in which the subscribers get the events). |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | The task to be awaited. |