How do I do "contemplation of death" meditation? And is it dangerous? How do I do "contemplation of death" meditation? And is it dangerous?

Because I read it might cause someone to commit suicide, so how do I make sure I won't reach that situation? And how exactly should I do this meditation - and for how long each time - and how many times each day?
How to do "contemplation of death" meditation ? 


With each and every in and out breath reflect: "life is impermanent, but death is certain, hence will attend to what need to be done without delay."


  
    “But how, bhikshu, do you cultivate the mindfulness of death?”
    
    “Here, bhante, I do it thus:
    
    'Indeed, should I live just the time it takes to breathe in and then out, to breathe out and then in,
    I would wisely attend to the Blessed One’s teaching, much indeed would be done by me!'
    
    Thus, bhante, I cultivate the mindfulness of death.”
  


Source: (Aṭṭhaka) Maraṇa,sati Sutta 1 and also similar passage is in: (Chakka) Maraṇa,sati Sutta 1

A more detailed outline of the pratice is covered in: Maraṇa Sati Kathā by Piya Tan


  and is it dangerous ?


Not if you pratice it correctly. Even crossing the road the wrong way will have dangers so does meditation. Key to do it the right way as with any other endeavor.

The intention of this pratice is to create urgency and eliminate procrastination as time is running out and what can be done within a lifetime ends with death. (Also see section How do you banish laziness?) Instead if you are developing a phobia or fear of death or some attraction to death or romanticizing with the concept of death or developing sorrow towards your pending death or of loved ones, then you are doing it wrong.


  Cause i read it might cause someone to suicide - so how do i make sure i won't reach that situation ? and how exactly should i do this meditation - ...


As far as I know repulsive meditation has resulted in suicides, but not sure on contemplation of death. These are 2 separate practices. The purpose of repulsive meditation is to counteract the perception of beauty in the form and shape of oneself and others and developing lust and taking pleasure and delight in such formations. If you are developing aversion towards the body one oneself as unclean or the perceived lack of beauty then you are doing it wrong.

Both these practices do also reinforce the perception of impermanence, more particularly impermanence of life as well as our corporal body.


  ... and for how long each time - ...


I think a few minutes will do or as much as to keep you motivated to attend to what need to be done without procrastination.

Also an occasional reminder on the need of urgency as time is running out during the day may be helpful.


  ... and how many times each day ?


(Aṭṭhaka) Maraṇa,sati Sutta 2 and (Chakka) Maraṇa,sati Sutta 2 mentions you should do it 2 times at least when the day has ended and when the night has ended. You contemplate some mishap can happen your life can end in the next part of the day hence be attentive to what needs to be done without fail.

Also see my answer to: Is contemplation of death auto-suggestion?