Due to the defects and flexibility of traditional centralized optimization methods, this paper adopts a method in a distributed manner to deal with the economic dispatch problem (EDP) of a cogeneration system. Heat price and electricity price of every unit are taken as the consistency variables, a consensus-based algorithm of electricity price and heat price is employed to solve the problem of traditional centralized economic dispatch in the form of a distributed way. Relative simulation results of several examples are given. The validity of the consensus algorithm in a distributed mode applied to solve the EDP in a combined heat and power (CHP) generation system can be demonstrated by the simulation results.