Deleting Child-Jobs

I have a Hangfire-Job which creates additional Jobs with continueWith…

If the first Job fails and or is restarting for some reason, I have to find all Jobs who are created with continueFor to delete them before they are recreated. So how could I get all jobs who are attached to a specific Parent JobID??

After a look in the Database where the information is stored for continuations, I came to the following solution:

Dim Continues = context.GetJobParameter(Of Object)(“Continuations”)
If Not Continues Is Nothing Then
For x = 0 To Continues.Count - 1
Dim y As Newtonsoft.Json.Linq.JObject = Continues(x)
Hangfire.BackgroundJob.Delete(y.GetValue(“JobId”))
Next
End If

1 Like