# CustomFunctionContext Class

> CustomFunctionContext class in the TX Sheet Control .NET API: Context for a host calculation callback; do not reenter the control from this callback.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Class
- **Namespace:** `TXTextControl.TXSheetControl.Server`
- **Package:** `TXTextControl.TXSheetControl.Server` (assembly `TXTextControl.TXSheetControl.Api.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Package:** `TXTextControl.TXSheetControl.Blazor` (assembly `TXTextControl.TXSheetControl.Api.dll`, from the private NuGet feed or the supplied NuGet folder)
- **Implements:** `System.IEquatable<TXTextControl.TXSheetControl.Server.CustomFunctionContext>`
- **Path:** TX Sheet Control > API Reference > .NET API > TXTextControl.TXSheetControl.Server > CustomFunctionContext Class
- **984 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/customfunctioncontext/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/customfunctioncontext/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/customfunctioncontext/llms-full.txt

---

Context for a host calculation callback; do not reenter the control from this callback.

### Syntax

```csharp
public class CustomFunctionContext
```

Interfaces: `IEquatable<CustomFunctionContext>`.

### Members

#### Constructors

| Constructor | Description |
|---|---|
| [Constructor](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/customfunctioncontext/constructor/llms-full.txt) |  |

#### Properties

| Property | Description |
|---|---|
| [Address](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/customfunctioncontext/address-property/llms-full.txt) | A1 address of the formula cell. |
| [CancellationToken](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/customfunctioncontext/cancellationtoken-property/llms-full.txt) | Cancellation for the active operation and document disposal. |
| [SheetId](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/customfunctioncontext/sheetid-property/llms-full.txt) | Worksheet identity containing the formula. |

### Examples

Create a working document workflow using CustomFunctionContext. Return the generated document or application data to the caller.

```csharp
using System.Text.Json;
using TXTextControl.TXSheetControl.Server;

async Task<byte[]> BuildCustomFunctionContextExampleAsync(ServerSheetControl control)
{
    var book = control.Workbook;
    var sheet = await book.Sheets.AtAsync(0);
    await sheet.Cell("B8").SetValueAsync(120);
    await sheet.Cell("B9").SetValueAsync(80);
    await sheet.Cell("B10").SetFormulaAsync("=SUM(B8:B9)");
    await book.Calculation.RegisterFunctionAsync("DOUBLE", (arguments, context) =>
    {
        context.CancellationToken.ThrowIfCancellationRequested();
        return JsonSerializer.SerializeToElement(arguments[0].GetDouble() * 2);
    }, new CustomFunctionOptions { MinArguments = 1, MaxArguments = 1 });

    await sheet.Cell("B10").SetFormulaAsync("=DOUBLE(B8)");
    return await control.SaveAsync(StreamType.PDF);
}
```

### See Also

- [TXTextControl.TXSheetControl.Server Namespace](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/llms-full.txt)
- [Formulas](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formulas/llms-full.txt)

---

## In This Section

- [CustomFunctionContext.Address Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/customfunctioncontext/address-property/llms-full.txt): CustomFunctionContext.Address property in the TX Sheet Control .NET API: A1 address of the formula cell. Covers its type string and a C# example.
- [CustomFunctionContext.CancellationToken Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/customfunctioncontext/cancellationtoken-property/llms-full.txt): CustomFunctionContext.CancellationToken property in the TX Sheet Control .NET API: Cancellation for the active operation and document disposal.
- [CustomFunctionContext Constructor](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/customfunctioncontext/constructor/llms-full.txt): CustomFunctionContext constructor in the TX Sheet Control .NET API, with its syntax, a C# example and remarks on awaiting tasks and handles.
- [CustomFunctionContext.SheetId Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/customfunctioncontext/sheetid-property/llms-full.txt): CustomFunctionContext.SheetId property in the TX Sheet Control .NET API: Worksheet identity containing the formula. Covers its type string and a C# example.

---

## Nearby

- **Previous:** [CsvSaveOptions.LineEnding Property](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/csvsaveoptions/lineending-property/llms-full.txt)
- **Next:** [CustomFunctionContext Constructor](https://docs.textcontrol.com/tx-sheet-control/reference/dotnet-api/txtextcontrol-txsheetcontrol-server/customfunctioncontext/constructor/llms-full.txt)
