Reputation: 24182
I am programming in .net WPF.
I have a (third party) API which implements the Begin/End asynchronous call pattern. The BeginWork() function returns an IAsyncResult.
However, there is no apparent method to cancel/abort the call, once done.
Is there a way to have such a job stopped? If this requires the library author to provide explicitly for a cancel method, what is a way to kill this job, even ungracefully? I really need to be able to stop it somehow, as a single job may take hours to complete!
Thanks!
Upvotes: 4
Views: 3114
Reputation: 1062650
If the implementation does not include specific code allowing for cancellation, then it is quite likely that you can't cancel it. Not everything can be logically cancelled cleanly, especially if it involves external resources. But also if the code to cancel it simply hasn't been written. .you could try randomly killing threads, but this will doom your process - basically this would be the same as deciding to kill the entire process half way through. It will stop the work, but it could leave things in a complete mess if it isn't transactional.
If I was you I would (one of):
Upvotes: 3