I have a long running process in a custom code activity. If I attempt to stop the build while this activity is running I get back the error:
TFS215104: Failed to stop build XXXXXXXXXXXXX: it did not respond to a
workflow cancellation request.
Then in the build log I see:
Cannot stop the build. Details: Operation did not complete in
00:00:59.9843747.Cannot cancel the workflow. Agent needs to be restarted. Details: The
operation did not complete within the allotted timeout of 00:01:00.
The time allotted to this operation may have been a portion of a
longer timeout.Service ‘XXXXXXX – Controller’: build ‘XXXXXXXXXXX’ was stopped.
Details: Build was cancelled.
How does this cancellation request make it back to my activity? I understand how to use background processes but I’m not sure how to capture the cancellation request inside my code.
Are you using the CodeActivity class as your base?
According to this, you might try AsyncCodeActivity as it supports Cancel.