Skip to main content

Working with tasks

In this step, we will extend the console application created in the previous step.

Creating a new task

Add the following code to your sample application to create your first task:

// Creating a sample task
var createTaskInput = new TaskConfig("testCommand")
{
ExternalId = "PO-578934",
Arguments = new List<TaskArgument>()
{
new TaskArgument("purchaseOrderId")
{
Value = "3000911e-ef4f-4420-9271-abd03373de32"
},
new TaskArgument("formatting")
{
Value = new
{
PaperSize = "Letter",
Orientation = "Portrait"
}
},
new TaskArgument("mailing")
{
Value = new
{
IncludePurchaseOrderAttachment = true,
Recipients = new List<string>()
{
"purchase@company.net",
"finance@company.net"
}
},
Sensitive = true
}
},
Category = "Purchase",
Subject = "Generate purchase order and email",
Description = "Generate purchase order PDF and email to recipients.",
};

var createdTask = taskurai.CreateTask(createTaskInput);

Console.WriteLine(JsonSerializer.Serialize(createdTask, serializerOptions));

Next, run the console application to validate:

dotnet run

The expected output should be similar to the following:

{
"id": "5e41080b-8599-4ad5-b6f4-d5cf38f49186",
"config": {
"command": "testCommand",
"arguments": [
{
"name": "purchaseOrderId",
"data": "3000911e-ef4f-4420-9271-abd03373de32"
},
{
"name": "formatting",
"data": {
"paperSize": "Letter",
"orientation": "Portrait"
}
},
{
"name": "mailing",
"sensitive": true,
"data": {
"includePurchaseOrderAttachment": true,
"recipients": [
"purchase@company.net",
"finance@company.net"
]
}
}
],
"secrets": [],
"category": "Purchase",
"subject": "Generate purchase order and email",
"description": "Generate purchase order PDF and email to recipients.",
"externalId": "PO-578934",
"tags": {},
"isolationMode": true,
"isolationKey": "dd10b001-addd-45c2-94a6-932282b7515c",
"correlationId": "5e41080b-8599-4ad5-b6f4-d5cf38f49186",
"traceParent": "00-5e41080b85994ad5b6f4d5cf38f49186-9d2199efe6a42807-01",
"id": "5e41080b-8599-4ad5-b6f4-d5cf38f49186"
},
"created": "2026-03-27T16:01:40.1667634+00:00",
"createdBy": "d8e9cb3f-ffeb-4915-bb15-6681a3bcd175",
"modified": "2026-03-27T16:01:40.2851177+00:00",
"modifiedBy": "d8e9cb3f-ffeb-4915-bb15-6681a3bcd175",
"status": "created",
"archived": false,
"postponed": false,
"deleting": false,
"correlationId": "5e41080b-8599-4ad5-b6f4-d5cf38f49186",
"defaultStateStore": "DefaultStateStore"
}

Isolation mode

Please note that the sample is running is isolation mode, since no local worker is running, the created tasks will remain in the Created status.

For more information about using Taskurai in local development, see Local Development.