A real-time, centralized control system is presented which is acting on the active and reactive powers of distributed generators when the network experiences voltage and/or thermal limits violation. The control resorts to multi-step receding horizon optimization. The objective is to minimize the deviations of Dispersed Generation Units (DGU) active and reactive powers from reference values. Furthermore, the formulation is such that DGU powers are restored to their desired schedule as soon as operating conditions allow doing so. Three modes of operation of the proposed controller are presented, involving dispatchable units as well as DGUs operated to collect maximum power