Yes, if you stop yourself from doing bad karma that is good karma. But good karma is not only in action but also in thought. If you stop the bad action but your mind still dwells on doing the bad action, then some bad karma still results from that, not as much as if you had done the bad action, but still some bad karma results.
Karma is not related to time; the karma produced is related to the actions involved, not time.
Karma can fructify in the future - there is no time limit on it. Perhaps some bad karma you do today does not come back to you for 3, 4, or 5 lifetimes. Other bad karma you do may result in the karma coming back right away. Perhaps ALL the karma of the present life is based on actions from a prior birth and no matter what you do in this life, that karma cannot be avoided. Only the Lord and your guru will know.
Krishna says in the Gita (2.47):
Your right is for action alone, never for the results. Do not become the agent of the results of action. May you not have any inclination for inaction.
Krishna is telling Arjuna to do his actions (dharmaic actions as prescribed in scriptures) in the world and not to hanker for their results, whether good or bad. Offer your actions up to the Lord and the Lord will take care of all good and bad karma. And in verse 2.49, the Lord says:
O Dhananjaya, indeed, action is quite inferior to the yoga of wisdom. Take resort to wisdom. Those who thirst for rewards are pitiable.
And in Chapter 18 Krishna says:
Verse 11. Since it is not possible for one who holds on to a body to give up actions entirely, therefore he, on the other hand, who renounces results of actions is called a man of renunciation.
Verse 47. One's own duty, (though) defective, is superior to another's duty well performed. By performing a duty as dictated by one's own nature, one does not incur sin.
Verse 48. O son of Kunti, one should not give up the duty to which one is born, even though it be faulty. For all undertakings are surrounded with evil, as fire with smoke.
As Ramakrishna Paramahamsa said, we are here to eat the mangoes in the orchard, not to count them. Do your duties (duties as prescribed by Dharma), offer the results up to the Lord, and do not worry about the results.