After Retrieve Logic Hook is running multiple times in a loop

Hi,

How to prevent after retrieve logic hook from executing more than once.
I tried session variables, static variable for locking but of nothing happened.

Thanks.