Why Do You Need a Cancellation Token in C# for Tasks?by@igorlopushko
51,444 reads

Why Do You Need a Cancellation Token in C# for Tasks?

tldt arrow
EN
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

When you run a task in C it may take a while to execute it. In some cases, you would like to cancel such a long operation. A CancellationToken(https://://://.ms.com/en-us/dotnet/api//system.threading.cancellating.tasks?view=net-6.0) enables cooperative cancellation between threads, thread pool work items, or Task(http://www.msn.org/s/windows-windows-tasks) The algorithm follows an algorithm to create an object that signals cancellation to the token. Pass the `CancellatedTokenSource.Token` property as a token object to the task.

Company Mentioned

Mention Thumbnail
featured image - Why Do You Need a Cancellation Token in C# for Tasks?
Igor Lopushko HackerNoon profile picture

@igorlopushko

Igor Lopushko


Receive Stories from @igorlopushko

react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa