Start Task With CancellationToken

PHOTO EMBED

Mon Aug 22 2022 11:20:19 GMT+0000 (UTC)

Saved by @HristoT #c#

CancellationTokenSource src = new CancellationTokenSource();
CancellationToken ct = src.Token;

await Task.Factory.StartNew(async () =>
{
     if (ct.IsCancellationRequested)
     {
         return;
     }
     
     // Do the logic here
},ct);
content_copyCOPY