When are Capital Gains actually realised?

Suggest you start by reading this thread: