Spectral fflow is a classical notion of functional analysis and differential geometry which was given different interpretations as Fredholm index, Witten index, and Maslov index. The classical theory treats spectral flow outside essential spectrum. Inside essential spectrum, the spectral shift function could be considered as a proper analogue of spectral flow, but unlike spectral flow, the spectral shift function is not an integer-valued function. In this paper it is flown that the notion of spectral flow admits a natural extension for a.e. value of the spectral parameter inside essential spectrum too, and an appropriate theory is developed. The definition of spectral flow inside essential spectrum given in this paper applies to classical spectral flow and thus provides one more new alternative definition of it. One of the results of this paper asserts that for trace class self-adjoint perturbations of selfadjoint operators the follflowing four integer-valued functions are equal almost everywhere. The common value of these functions is spectral flow inside essential spectrum by definition. 1) Singular spectral shift function. 2) Singular part of the Pushnitski ĉ-invariant. 3) The so-called total resonance index. 4) The so-called total signature of resonance matrices. Equality of the third and the fourth functions is proved under much weaker assumptions which cover Schrödinger operators. Some applications of this result are given.