Events

An event allows a method to be executed when an event is raised. You subscribe to events in the code, and the method will be executed every time the event is called. We'll show you where to subscribe and unsubscribe from event handlers in ARC.


Subscribe to Events

When your robot skill loads, you can subscribe to events. It's best to subscribe to events in the FormLoad event for your form. Here are the steps to create a FormLoad event for your robot skill. Once the form has been loaded and rendered to the screen, this method will be called. Notice that the subscription has a +=, which means subscribe.

  1. Select the FormMain, so the designer views it. This is when you can see the buttons, etc.

  2. Navigate to the Events for the form in the properties panel

  3. Locate the Form Load event

  4. Double click in the empty area next to the Form Load event

  5. A new event will be created


  6. This is the method where you will place the subscribe commands for your robot skill.



Unsubscribe from Event

The events must be unsubscribed when the robot skill is removed from the project. The robot skill is gone, so the event methods no longer exist, or their resources won't. The best place to unsubscribe from events is in the FormClosing event. This is similar to the process you executed in the Subscribe to Events instructions. The only difference is a -= means unsubscribe.

  1. Select the FormMain, so the designer views it. This is when you can see the buttons, etc.

  2. Navigate to the Events for the form in the properties panel

  3. Locate the Form Closing event

  4. Double click in the empty area next to the Form Closing event

  5. A new event will be created


  6. This is the method where you will place the unsubscribe commands for your robot skill.