Assuming I have a very long running operation that does not contain any loop, I mean the nature of the operation is long running without any recursion and repetition. In this case if I use the CancellationToken
type to throw a cancelling exception or a Boolean
Flag for "Safely" cancelling the task, the token or flag can never be reached.
Now the only goal would be to break the running task regardless of whether aborting is a good or bad approach. When using threads, the abort method is present (I'm not interested in discussing about it's disadvantages as I'm already aware of it), but when it comes to the Task type, I don't see it there. And assuming my Task has to return a value, then threads are out of questions.
What is the safest and most efficient way to implement this.