This paper proposes an optimal scheduling problem model for multi-carrier energy systems (MCESs) considering electrical, heating, and cooling energy markets. The MCES transacts energy with multiple distributed energy resources. Further, the MCES has multi-carrier energy resources. The main contribution of this paper is that the model simultaneously considers a six-stage optimization process of MCES for the electrical, heating, and cooling markets in the day-ahead and real-time horizons. Further, the proposed algorithm for solving the model is another contribution of this paper. In the first and second stages, the operating scheduling of MCES for the day-ahead horizon is optimized in the normal and alert states, respectively. It is suggested that preventive actions should be considered for probable extreme external shocks in the second stage. In the third and fourth stages, the models optimize the decision variables of the real-time scheduling problem in the normal and alert states, respectively. In the fifth stage, different external shock scenarios are considered, and corrective actions are performed for on-outage zones. Finally, in the sixth stage, the preventive/corrective actions are carried out for the post-event conditions when the MCES is recovered. The proposed model was assessed by the modified 123-bus test system. The algorithm reduced the expected costs by about 44.31% concerning the base case. Further, the model increased the defined resiliency index of MCES to infinity for the sixth-stage problem based on the fact that all of the multi-carrier loads were supplied using the proposed process.