We consider electron motion in quantum waveguides with variable cross-sections. The narrows of the waveguide play the role of effective potential barriers for the longitudinal motion of electrons. Two narrows form a quantum resonator where a resonant tunneling can occur. It means that electrons with energy in a small range pass through the resonator with probability near to 1. In presence of magnetic field, the aforementioned range splits into two intervals. Electrons with spin +1/2 can pass through the resonator only if their energies are in one of these intervals and electrons with spin -1/2 can pass only having energies in the second one. Hence, all electrons in the outgoing flow have similarly oriented spins, i. e. The electron flow becomes polarized. The intervals are rapidly decreasing as the diameter of narrows tends to 0, which presents difficulties for numerical simulation of the phenomenon. The full qualitative description of the phenomenon can be given only by asymptotic analysis. We consider an infinite waveguide with two cylindrical ends and two narrows of small diameter. Part of the resonator is placed into magnetic field. We give an asymptotic description of the electron wave propagation in such a waveguide as diameters of the narrows tend to zero.