Class Event
Definition
- Assembly:
- Tizen.Core.dll
Represents the event used for broadcasting events.
public 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
View SourceEvent()
Constructor for creating a new event instance.
Declaration
public 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:
Create 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
View SourceDispose()
Release any unmanaged resources used by this object.
Declaration
public 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.
Dispose(bool)
Release any unmanaged resources used by this object.
Declaration
protected 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
public 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
var 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. |
~Event()
Finalizes an instance of the Event class.
Declaration
protected ~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
View SourceEventReceived
Occurrs whenever the event is received in the main loop of the task.
Declaration
public 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
var coreEvent = new Event();
coreEvent.EventReceived += (s, e) => {
Console.WriteLine("OnEventReceived. Message = {}", (string)e.Data);
};