Jan 23, 2022 10:55 AM
(This post was last modified: Jan 23, 2022 10:57 AM by Lookdadon.)
Hi, i made a program that run asynchronously and i added CancelTokenSource to my code but realised that the way it cancel the task is by throwing an exception. Even in a try/catch/finally the problem is that it still throw an exception. After research and alot of readings, i learnt that this is how it work, using the canceltokensource stop the task by throwing an exception but when you run the .exe stopping throw an error and ask you to continue and ignore the cancel event or quit program...
Is there another way to stop your code to run once a stop button is pressed? I dont want to thread sleep or wait i wanna know if there is a way to straight stop your code. There must be a way to do it.
Thanks in advance
Is there another way to stop your code to run once a stop button is pressed? I dont want to thread sleep or wait i wanna know if there is a way to straight stop your code. There must be a way to do it.
Thanks in advance


![[Image: wOtOOxQ.png]](https://i.imgur.com/wOtOOxQ.png)
![[Image: lolj.png]](https://i.ibb.co/1zYW3qZ/lolj.png)