Class Event
Definition
- Assembly:
- Tizen.Core.dll
Represents the event used for broadcasting events.
C#Copypublic class Event : IDisposable
- Inheritance
-
objectEvent
- Implements
-
System.IDisposable
Remarks
This class provides functionality for managing events that are broadcasted across multiple components in an application. It enables communication between different parts of the code without resorting to direct references or global variables. By implementing the IDisposable interface, it ensures proper resource management and prevents memory leaks.
Constructors
Declaration
C#Copypublic Event()
Remarks
This constructor initializes a new event instance. It may throw exceptions if there are any issues during initialization such as running out of memory or performing an invalid operation.
Examples
Here's an example showing how to create a new event instance:
CopyCreate a new event instance var coreEvent = new Event();
Exceptions
| Type | Condition |
|---|---|
| System.OutOfMemoryException | Thrown when out of memory. |
| System.InvalidOperationException | Thrown when failed because of an invalid operation. |
Methods
Declaration
C#Copypublic void Dispose()
Remarks
This class provides functionality for managing events that are broadcasted across multiple components in an application. It enables communication between different parts of the code without resorting to direct references or global variables. By implementing the IDisposable interface, it ensures proper resource management and prevents memory leaks.
Declaration
C#Copyprotected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing | If true, disposes any disposable objects. If false, does not dispose disposable objects. |
Remarks
This class provides functionality for managing events that are broadcasted across multiple components in an application. It enables communication between different parts of the code without resorting to direct references or global variables. By implementing the IDisposable interface, it ensures proper resource management and prevents memory leaks.
Emit(EventObject)
Emits an event object to the event. The emitted event object is queued and delivered to the registered EventHandlers on the main loop of the task.
Declaration
C#Copypublic void Emit(EventObject eventObject)
Parameters
| Type | Name | Description |
|---|---|---|
| EventObject | eventObject | The event object instance. |
Remarks
If the event is not added to the task, the emitted event object will be pended until the event is added to the task.
Examples
Copyvar coreEvent = new Event(); coreEvent.EventReceived += (s, e) => { Console.WriteLine("OnEventReceived. Message = {}", (string)e.Data); }; var task = TizenCore.Find("EventTask"); if (task != null) { task.AddEvent(coreEvent); string message = "Test Event"; using (var eventObject = new EventObject(1, message)) { coreEvent.Emit(eventObject); } }
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when the argument is null. |
| System.InvalidOperationException | Thrown when failed because of an invalid operation. |
Declaration
C#Copyprotected ~Event()
Remarks
This class provides functionality for managing events that are broadcasted across multiple components in an application. It enables communication between different parts of the code without resorting to direct references or global variables. By implementing the IDisposable interface, it ensures proper resource management and prevents memory leaks.
Events
Declaration
C#Copypublic event EventHandler<EventReceivedEventArgs> EventReceived
Event Type
| Type | Description |
|---|---|
| System.EventHandler<TEventArgs><EventReceivedEventArgs> |
Remarks
The registered event handler will be invoked when the event is added to the specific task.
Examples
Copyvar coreEvent = new Event(); coreEvent.EventReceived += (s, e) => { Console.WriteLine("OnEventReceived. Message = {}", (string)e.Data); };