Showing posts with label postexecute. Show all posts
Showing posts with label postexecute. Show all posts

Monday, March 26, 2012

Pre and PostExecute Event handler called more than once

I have a task configured on the post execute event handler of a package expecting this task to be executed only once after the completion of all the other tasks in the package. But I found the task configured on the post execute event of the package getting executed as many times as the number of tasks in the package + 1 . Is there any workaround for this problem?

Yes,

The reason this happens is that events "bubble-up" from a container to all parent containers and are caught by any eventhandlers that exist on those parent containers.

To stop this behaviour you'll need to create an eventhandler scoped to each task's OnPreExecute & OnPostExecute eventhandlers and set [@.System::Propogate]=FALSE. This will stop the event "bubbling-up".

-Jamie

Wednesday, March 21, 2012

PostExecute() and Cleanup()

So when do I use which and why? BOL pretty much makes them the same but I figure there must be a difference rather like PreExecute is the first opportunity to get our hands on the BufferManager so maybe PostExecute is our last chance?

Thanks

AllanHi Allan,

In general PostExecute and Cleanup are the same and as a rule of thumb anything you did in PreExecute you cleanup in PostExecute and anything you did in PrepareForExecute you clean up in Cleanup. However, that is not required. You might ask why there are two if they are the same. The answer is that there were thoughts about using one as a one shot and the other as called every time (think looping). However, currently this is not the case and they are interchangeable just as PrepareForExecute and PreExecute.

HTH,|||Hi Matt

Yes that was a Q i was asking myself but thanks for clearing this up.

Allan