I spent two hours (in) doing my homework.
I spent two hours on my homework.
It took me two hours to do my homework.