Ben Foster
Ben Foster

Reputation: 34800

What is the correct way to end a System.Threading.Tasks.Task?

As per the title really.

I have a long running task that polls a message queue.

Occasionally I may wish to stop the task, do some work and then start it again. What is the correct way of doing this?

Upvotes: 5

Views: 3002

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038720

The proper way of stooping tasks is using cancellation tokens.

Upvotes: 5

Related Questions