1. Thomas Rolseth
  2. SnapDevelop
  3. Monday, 4 October 2021 14:33 PM UTC

Per the SnapDevelop documentation, the RetrieveAsync method takes a cancellationtoken parameter to make an operation cancelable (see link below) and throws an exception in the TRY/CATCH block if that if that happens. How is that done in practice though?  If a user wants to cancel an operation in the PowerBuilder client calling the rest API, how would that be handled in the code?  I'd love to see some example script of how this would typically be done.

Thanks, Tom

 

https://docs.appeon.com/net_datastore/3.0/api_reference/DWNet.Data/DataStore/IDataStoreBase/Method/RetrieveAsync2.html

 

Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Monday, 4 October 2021 15:51 PM UTC
  2. SnapDevelop
  3. # 1

Hi Thomas,

Here's a link to Microsoft's documentation on how Cancellation Tokens work. They can't be used as you describe, though. They're used to help with manual cancellation of threads by an owning thread. You cannot cancel an already ongoing operation on a REST API. If you have a long-running operation that should be cancelable, what you can do is create a job queue on the server to handle long-running operations and let the Web API and the Job Queue communicate with each other using message brokers. You would have to expose another set of endpoints for canceling the jobs, and the way to cancel these jobs is particular to the job queue's implementation.

This is a very good read on the topic: https://stackoverflow.com/questions/14710822/how-to-queue-background-tasks-in-asp-net-web-api

I hope this helps!

Regards,
Francisco

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.