Reputation: 10296
Is there any way to detect when the OS kills a ScheduledTaskAgent for example if it exceeds the allotted execution time? I need to guard against concurrent database updates performed by the Application Frontend or the Background Agent. But unless my agent knows when its going to be killed it has no chance to release the global Mutex guarding the update code. Thus blocking updates forever. Is there a solution for this?
I know that the BackgroundAgent class contains an OnCancel method that would accomplish exactly what I was looking for. Unfortunately its marked internal.
Upvotes: 0
Views: 231
Reputation: 84754
Have you tried putting the release of the mutex in a finally
block might work. It's possible that a ThreadInterrupt-style exception is thrown, so the finally code should still run.
Upvotes: 1