.NET
import { Aside } from ‘@astrojs/starlight/components’;
Quickstart
Historical package install steps below. Prefer check-in recipes for new setups.
Get from zero to your first data in under 3 minutes.
1. Prerequisites
- .NET 8.0+ or .NET Standard 2.0
- A Crontinel account (sign up free)
- An app created in the dashboard
- Your API key (
crn_live_...) from app settings
2. Install
dotnet new console -n Quickstartcd Quickstartdotnet add package Crontinel3. Configure
Edit Program.cs:
using Crontinel;using Crontinel.Models;
var apiKey = Environment.GetEnvironmentVariable("CRONTINEL_API_KEY") ?? throw new InvalidOperationException("CRONTINEL_API_KEY not set");
var client = new CrontinelClient(apiKey);
await client.ScheduleRunAsync(new ScheduleRunOptions{ Command = "hello-from-dotnet", DurationMs = 100, ExitCode = 0});
Console.WriteLine("Data sent to Crontinel!");Set your API key and run it:
export CRONTINEL_API_KEY=crn_live_xxxxxxxxxxxxdotnet run4. Dashboard verification
- Go to app.crontinel.com → Apps → your app
- Check the Cron section — you should see the
hello-from-dotnetjob with exit code0and100msduration - Your first data is on the dashboard!
Requirements
- .NET 8.0+ or .NET Standard 2.0
Install
dotnet add package CrontinelQuick Start
using Crontinel;using Crontinel.Models;
var client = new CrontinelClient( Environment.GetEnvironmentVariable("CRONTINEL_API_KEY")!);
// Report a cron job runawait client.ScheduleRunAsync(new ScheduleRunOptions{ Command = "reports:generate", DurationMs = 2340, ExitCode = 0 // 0 = success, non-zero = failure});
// Report queue worker activityawait client.QueueProcessedAsync(new QueueProcessedOptions{ Queue = "emails", Processed = 12, Failed = 0, DurationMs = 8901});MonitorScheduleAsync helper
Wrap any async function and automatically report its outcome:
var result = await client.MonitorScheduleAsync("reports:generate", async () =>{ await SendDailyReports(); return true;});
Console.WriteLine($"Duration: {result.DurationMs}ms, ExitCode: {result.ExitCode}");If the inner function throws, the exception propagates and ExitCode is set to 1.
ASP.NET Core / Worker Service
Register as a singleton in Program.cs:
builder.Services.AddSingleton<CrontinelClient>(_ => new CrontinelClient( Environment.GetEnvironmentVariable("CRONTINEL_API_KEY")! ));Use in a hosted service:
public class MyWorker : BackgroundService{ private readonly CrontinelClient _crontinel;
public MyWorker(CrontinelClient crontinel) => _crontinel = crontinel;
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { await _crontinel.MonitorScheduleAsync("my-worker-tick", async () => { await DoWorkAsync(); }, stoppingToken);
await Task.Delay(TimeSpan.FromMinutes(1), stoppingToken); } }}Hangfire integration
using Crontinel;using Crontinel.Models;
var client = new CrontinelClient(apiKey);
RecurringJob.AddOrUpdate("sync-data", async () =>{ await client.MonitorScheduleAsync("sync-data", async () => { await DataSyncAsync(); });}, Cron.Hourly);Configuration
var client = new CrontinelClient(new CrontinelOptions{ ApiKey = "your-api-key", ApiUrl = "https://app.crontinel.com", // optional, defaults to SaaS AppName = "my-service", // optional, default: "dotnet" UserAgent = "my-app/1.0" // optional});Environment variables
The .NET SDK does not read environment variables automatically. Pass values explicitly via CrontinelOptions or set them in your app’s configuration and inject them at construction time.