Property IsCancelled
IsCancelled
Gets a value indicating whether the execution was cancelled.
public bool IsCancelled { get; }
Property Value
Examples
Handling cancellation:
using LMKit.Model;
using LMKit.Agents;
using var model = new LM("path/to/model.gguf");
var agent = new Agent(model);
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
var result = await agent.RunAsync("Write a long essay.", cts.Token);
if (result.IsCancelled)
{
Console.WriteLine("Task was cancelled (timeout or user request).");
// Partial content might be available
if (!string.IsNullOrEmpty(result.Content))
{
Console.WriteLine($"Partial result: {result.Content}");
}
}