>1. ~When (to achieve a purpose)
>2. ~To express surprise or disappointment or even dissatisfaction.
登<る>のに3時間かかりました。
if the verb is a so-called present tense, then it is (1).
頂上まで登っ<た>のに何もありませんでした。
if the verb is so-called past tense, then it is (2).
おれが真面目に話し<ている>のに、おまえのその態度は何だ!
if the verb is a so-called present progressive tense, then it is (2).
You can tell them at 99% using this criterion.