Is OnPerformed in IServerFilter called when there is an error inside the job?


I need to run some code before and after the job is finished. (So for example, creating a database connection, and closing it when the job is complete).

I don’t want to do this in the job itself, because when the code runs in its normal application there already is a database connection.

I found the JobFilters (, and i would like to know if OnPerformed is called even when an error happened in the job, or is there a better way to always execute code before and after a job?

Unfortunately i can’t do the following thing:
BackgroundJob.Enqueue(()=> { using(var con = new Connection()) { ClassA.ExecuteJob() } )

The answer is yes, it get’s called even if there is an exception in the method. Maybe not the appropriate tool for my job (abusing attributes to do specific initialization logic), but it works!