> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/examples/kscoroutine.md).

# Coroutines

## Summary

Use Coroutines in Reactor server scripts. A coroutine is a function suspend (yield) it's execution and resume it later. They are useful for scripting behaviours that take place over many frames, such as NPC behaviours that involve waiting.

## Description

ksCoroutine is the equivalent to Unity Coroutine for server scripts. Use `yield return null;` to suspend execution until the next frame.

```c#
using KS.Reactor;
using KS.Reactor.Server;

/**
 * Wait one second then log out a message.
 */
public class srRoom : ksServerEntityScript
{
    public override void Initialize()
    {
        Room.Coroutines.Start(WaitOneSecond());
    }

    private IEnumerator WaitOneSecond()
	{
		yield return Room.Coroutines.Sleep(1f);
		ksLog.Info("1 second has passed");
	}
}
```
