com.brightcove.player.event

## Class BackgroundEventListener

- java.lang.Object
- - com.brightcove.player.event.BackgroundEventListener

- All Implemented Interfaces:
    EventListener

      public abstract class BackgroundEventListener
      extends java.lang.Object
      implements EventListener

  Implements an `EventListener` and calls `processEvent` on a background thread. By default, EventListener calls processEvent on the main thread. This class is useful for custom analytics implementation, or other types of event handlers that need to do work on a background thread (typically to make network calls). When extending this class, `destroyBackgroundThread()` must be called when this class is no longer needed. Otherwise, if this method is not called, the background thread will live on until the app it is running in, is terminated.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BackgroundEventListener()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `backgroundProcessEvent(Event event)` Process a given event to some purpose.
    `void` | `destroyBackgroundThread()` Stops and destroys the background thread.
    `void` | `processEvent(Event event)` Process a given event to some purpose.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BackgroundEventListener

          public BackgroundEventListener()

  - ### Method Detail

    - #### processEvent

          public final void processEvent(Event event)

      Description copied from interface: `EventListener`
      Process a given event to some purpose. The event can contain or provide payload data via properties.
      Specified by:
        `processEvent` in interface `EventListener`
      Parameters:
        `event` - The given event.

    - #### backgroundProcessEvent

          public abstract void backgroundProcessEvent(Event event)

      Process a given event to some purpose. The event can contain or provide payload data via properties. Called from a background thread.
      Parameters:
        `event` - The event to process

    - #### destroyBackgroundThread

          public void destroyBackgroundThread()

      Stops and destroys the background thread. This must be called once the EventListener is no longer required. Failure to do so will result in the background thread continuing to run until the app is terminated.