تخطَّ إلى المحتوى

Use cancellation token overload (ARCH106)

هذا المحتوى غير متوفر بلغتك بعد.

Key dotnet.async.use-cancellation-token-overload · Severity warning · Category async

When a method has an overload that accepts a CancellationToken, pass the available token to that overload. Otherwise cancellation requests never reach the downstream call.

public async Task SaveAsync(Order order, CancellationToken cancellationToken)
{
await _context.SaveChangesAsync();
}
public async Task SaveAsync(Order order, CancellationToken cancellationToken)
{
await _context.SaveChangesAsync(cancellationToken);
}

Call the existing CancellationToken overload and pass the token. If needed, suppress the rule per project/workspace via except/ignore.