ThingWorx Edge .NET SDK > ThingWorx Edge .NET SDK Reference > .NET SDK: VirtualThing Class > .NET SDK: EventDefinition Class
.NET SDK: EventDefinition Class
Event definitions describe interrupts that the ThingWorx platform can subscribe to in order to receive notifications when a particular event occurs. The most effective and maintainable way to define events in code is by using attributes, as listed in the section below. An event also requires the definition of a DataShape in code to characterize the data of the event.
To create an event, call the defineEvent method on the base VirtualThing. There are two defineEvent methods, one that takes an EventDefinition, and one that takes the essential parameters for an EventDefinition:
defineEvent(EventDefinition eventDefinition)

defineEvent(String name, String description, String dataShape, AspectCollection aspects)
The examples used in this section define the following DataShape. This code should be placed in the constructor or in a method called from the constructor:
FieldDefinitionCollection fields = new FieldDefinitionCollection();

new FieldDefinition("ErrorMessage", BaseTypes.STRING));

this.defineDataShapeDefinition("ErrorEventShape", fields)
EventDefinition Attributes
The following attributes are available on the EventDefinition class (in the example below, ThingworxEventDefinition):
aspects — The AspectCollection for the event definition.
category — A category name for the event.
dataShape — The name of the data shape for the event data.
description — A description for the event.
isInvocable — Specifies whether the event can be invoked from code.
isPropertyEvent — Specifies whether the event is associated with a property.
name — Name of the event.
The following example defines a basic EventDefinition, and references the required DataShape (ErrorEventShape):
description="Event that sends an error",
The example below defines a basic EventDefinition, and references the required DataShape (ErrorEventShape):
"Event that sends an error",