We consider a compound Poisson process whose jumps are modelled as a sequence of positive, integer-valued, dependent random variables, W
1,W
2,…, viewed as insurance claim amounts. The number of points up to time t of the stationary Poisson process which models the claim arrivals is assumed to be independent of W
1,W
2,…. The premium income to the insurance company is represented by a nondecreasing, nonnegative, real-valued function h(t) on [0,∞) such that lim
t→∞
h(t) = ∞. The function h(t) is interpreted as an upper boundary. The probability that the trajectory of such a compound Poisson process will not cross the upper boundary in infinite time is known as the infinite-horizon nonruin probability. Our main result in this paper is an explicit expression for the probability of infinite-horizon nonruin, assuming that certain conditions on the premium-income function, h(t), and the joint distribution of the claim amount random variables, W
1,W
2,…, hold. We have also considered the classical ruin probability model, in which W
1,W
2,… are assumed to be independent, identically distributed random variables and we let h(t)=u + ct. For this model we give a formula for the nonruin probability which is a special case of our main result. This formula is shown to coincide with the infinite-horizon nonruin probability formulae of Picard and Lefèvre (2001), Gerber (1988), (1989), and Shiu (1987), (1989).