İçeriğe geç

Use ThrowIfCancellationRequested (CA2250)

Anahtar dotnet.async.use-throwifcancellationrequested · Önem info · Kategori async

Microsoft analizörü CA2250. OperationCanceledException fırlatan elle yazılmış IsCancellationRequested kontrolünü işaretler; ThrowIfCancellationRequested aynı işi yapar ve token’ı da taşır.

if (cancellationToken.IsCancellationRequested)
throw new OperationCanceledException();
cancellationToken.ThrowIfCancellationRequested();