The benefit of using dedicated in-beam positron emission tomography (PET) detectors in the treatment room instead of commercial tomographs nearby is an open question. This work quantitatively compares the measurable signal for in-beam and offline PET imaging, taking into account realistic acquisition strategies at different ion beam facilities. Both scenarios of pulsed and continuous irradiation from synchrotron and cyclotron accelerators are considered, because of their widespread use in most carbon ion and proton therapy centers. A mathematical framework is introduced to compare the time-dependent amount and spatial distribution of decays from irradiation-induced isotope production. The latter is calculated with Monte Carlo techniques for real proton treatments of head-and-neck and paraspinal tumors. Extrapolation to carbon ion irradiation is based on results of previous phantom experiments. Biologic clearance is modeled taking into account available data from previous animal and clinical studies. Ratios between the amount of physical decays available for in-beam and offline detection range from 40% to 60% for cyclotron-based facilities, to 65% to 110% (carbon ions) and 94% to 166% (protons) at synchrotron-based facilities, and increase when including biologic clearance. Spatial distributions of decays during irradiation exhibit better correlation with the dose delivery and reduced influence of biologic processes. In-beam imaging can be advantageous for synchrotron-based facilities, provided that efficient PET systems enabling detection of isotope decays during beam extraction are implemented. For very short (<2 min) irradiation times at cyclotron-based facilities, a few minutes of acquisition time after the end of irradiation are needed for counting statistics, thus affecting patient throughput.