How to enter while loop on a posedge of a trigger?

In reply to sdesai:

Your description is not very clear. If you want to wait for a posege of trigger that would be

task mytask()
      @( posedge my_if.trigger )
        :
        :
endtask

If you want a loop that begins at every posedge, that would be

task mytask()
      forever @( posedge my_if.trigger) begin
        :
        :
      end
endtask

You would need to explain what, if anything, needs to happen to get out of the loop.