C# Code Actions

Take full control of with custom code actions.


When you add a new Execute C# Code sub-action, you will be greeted with the following code snippet:

Execute C# Code Action
using System;

public class CPHInline
    public bool Execute()
        // your main code goes here

        return true;

For every execute code sub-action, this is the minimum that must be present for it to function.

You can return false to stop execution of the current action, including any subsequent sub-actions.

Within your Execute() function, you have access to the CPH class, allowing you to make calls to internal methods.

Explore all available C# methods at API References > C# Methods
CPH refers to the original development name of, ChannelPointsHandler


C# actions have access to a Dictionary<string, object> propertry named args

This property contains all variables from the current argument stack.


It is best practice fetch args with CPH.TryGetArg, added in v0.2.3.

If you attempt to access an argument by calling it directly via args["argName"] and it does not exist, a KeyNotFound exception will be thrown.

You can also check if a key exists with the general C# methods ContainsKey or TryGetValue.

// NOTE: CPH.TryGetArg requires 0.2.3 or later

// If %rawInput% exists, store it in rawInput
CPH.TryGetArg("rawInput", out string rawInput);

// Log the result
CPH.LogInfo($"Variable rawInput: {rawInput}");


Special arguments eventSource and __source must be accessed with their corresponding methods:
EventSource source = CPH.GetSource(); // eventSource in args

Lifecycle Methods

In addition to the Execute() method, you can also implement the lifecycle methods outlined below.

All lifecycle methods are optional


Executed when your code is first compiled, useful if you need to perform any initialization steps.

public void Init()
    // place your init code here


Executed on destroy, useful when you need to perform some cleanup.

public void Dispose()
    // place your dispose code here


Tools C# Snippets

Visual Studio Code plugin by Ik1497

Video Tutorials

C# Crash Course for

by nutty C# Shorts

by TerrierDarts