In a driver, I have a button to force a refresh.
This refresh run a comparison between the actual elements provisioned in the DMS and the elements expected to be provisioned in a database.
The processing can take a long time (several hours) and I would like to add the possibility to cancel the task. For the moment only a restart of the element allows to do this.
How can I catch this cancel and stop the processing?
In addition to what Joao indicated I like to mention that it is best practice to keep the execution time of a qaction-run as small as possible.
In your use-case, you know the action (the end goal) you want to perform will take a lot of time. In those scenario's I advise to chunk the action into smaller pieces and run the execution loop of those smaller pieces via groups. This will allow you to add not only a cancel flow ( = stopping the execution loop), but also any other action increasing the user interaction/satisfaction and keeping the DataMiner Watchdog safety ( not using queued option) to verify if something drastically went wrong.
Also keep in mind that a click on a button that will trigger a QAction will block the SetParameter Thread until that click can be seen as finished = QAction logic has finished. This means that any other sets are impacted (delayed). So it is really better to chunk the actions to perform into smaller bits and execute them via the execution of groups. iso of running everything at once in 1 QAction thread.
Thank you for your advice