Coroutine adds the ability to run coroutines. Coroutines are methods that run in parallel to the rest of the application through the use of an `Enumerator`. This allows for the coroutine to pause execution using the `yield return` statement.
There are two predefined ways to pause a coroutine:
- Waiting for a certain amount of seconds to have passed
- Waiting for a certain custom event to occur
Additionally, Coroutine provides the following features:
- Creation of custom events to wait for
- No multi-threading, which allows for any kind of process to be executed in a coroutine, including rendering
The `CoroutineHandler` is the place where coroutines get executed. For this to occur, the `Tick` method needs to be called continuously. The `Tick` method takes a single parameter which represents the amount of time since the last time it was called. It can either be called in your application's existing update loop or as follows.
To create a coroutine, simply create a method with the return type `IEnumerator<Wait>`. Then, you can use `yield return` to cause the coroutine to wait at any point:
To use an event, an `Event` instance first needs to be created. When not overriding any equality operators, only a single instance of each event should be used.
```cs
private static readonly Event TestEvent = new Event();
```
Waiting for an event in a coroutine works as follows: