Only executing the last coroutine

I have a function which has a yield in it. it’s called when user clicks a button and increases a variable. however I want the instructions after my yield to be executed only once and with every click I want the previous coroutine to be terminated and only the last coroutine remain so if the user keeps clicking my button it only executes the last coroutine. here’s a sample code :

var myNum = 0;
function sample(){
yield WaitForSeconds(2.0f);
myNum++;
}

I did this and this way it only executes the last coroutine :

var myNum = 0;
var yieldCnt1 = 0;
var yieldCnt2 = 0;

function sample(){
   yieldCnt1++;
   yield WaitForSeconds(2.0f);
   yieldCnt2++;
   if(yieldCnt1 != yieldCnt2)
      return;
   myNum++;
}