> For the complete documentation index, see [llms.txt](https://giantgrey.gitbook.io/flowreactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://giantgrey.gitbook.io/flowreactor/in-depth/long-running-nodes.md).

# Long running nodes

With FlowReactor version 2.0 it is possible to create nodes which run in a loop with async code.

{% hint style="info" %}
Coroutine nodes have been deprecated since version 2
{% endhint %}

### Example 1

This will run the node as long as its graph owner stays active. Use a sub-graph to activate / deactive such nodes.

```csharp
public override async void OnExecute(FlowReactorComponent _flowReactor)
{	
	// Run code in a loop
	while(graphOwner.isActive)
	{
		Follow();
		await Task.Yield();
	}
}
```

### Example 2

{% hint style="info" %}
It is also possible to execute the next connected node while still running itself.
{% endhint %}

First we call ExecuteNext() to execute the connected node, then we run our loop.\
If the node gets deactivated, we call StopExecution to make sure the node highlight gets deactivated.

```csharp
public override async void OnExecute(FlowReactorComponent _flowReactor)
{	
	// Execute output
	ExecuteNext(0, _flowReactor, true);
	// Run code in loop
	while(graphOwner.isActive)
	{
		Follow();
		await Task.Yield();
	}
	// Deactivate node highlight, should this node get deactivated
	StopExecution();
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://giantgrey.gitbook.io/flowreactor/in-depth/long-running-nodes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
